Büyük bir sorunum var doktorum bana yeni bir hesap makinesi (clojure) kullanarak hesap yapmamı istiyor ama bu konuda bir şey bilmiyorum biraz bilgi oku böylececlojure dilinde bir kod çalıştırmak için adımlara gereksinim var java'da GUI içerir
(ns rayne.main
(:gen-class)
(:import (javax.swing JFrame JTextField JButton JOptionPane)
(java.awt.event ActionListener)
(java.awt GridLayout)))
(def numbers (ref []))
(def times-clicked (ref 0))
(defn calc [nseq op]
(let [n1 (first nseq)
n2 (last nseq)]
(cond
(= op "+") (+ n1 n2)
(= op "*") (* n1 n2)
(= op "-") (- n2 n1)
(= op "/") (/ n1 n2))))
(defn add-op-button [op text button]
(.addActionListener button
(proxy [ActionListener] []
(actionPerformed [e]
(dosync
(ref-set times-clicked (inc @times-clicked))
(if (= @times-clicked 2)
(do
(let [result (.toString (calc @numbers op))
result2 (read-string result)]
(.setText text result)
(ref-set numbers [])
(ref-set times-clicked 0)))
(do
(ref-set numbers (conj @numbers (read-string (.getText text))))
(.setText text ""))))))))
(defn -main []
(let [frame (JFrame. "Calculator")
add-button (JButton. "+")
sub-button (JButton. "-")
mul-button (JButton. "*")
div-button (JButton. "/")
clr-button (JButton. "Clear")
text-field (JTextField.)]
(add-op-button "+" text-field add-button)
(add-op-button "-" text-field sub-button)
(add-op-button "*" text-field mul-button)
(add-op-button "/" text-field div-button)
(doto frame
(.setLayout (GridLayout. 1 5))
(.add text-field)
(.add add-button)
(.add sub-button)
(.add mul-button)
(.add div-button)
(.setSize 500 100)
(.setVisible true))))
: ama hala nasıl başka bir zaman çalıştırmak için bir dosyada kodu kaydetmek için bir sorun var ve ben Clojure için java nasıl bağlanacağını yola ihtiyacım www.clojure.org dan ben bu kodu bulundu Bunu test etmeye çalışıyorum nasıl çalıştığını bilmiyorum. lütfen bana bu problemde yardımcı olacak bir tane lazım ve böyle bir dosyayı yürütmek için bir clojure programı yüklemek için bana bir link gönderin. thank için tüm
Biçimlendirmek için dört boşluk girintile doğru biçimlendirmek için –
girintisine kodu gir –
Soruyu anlayamadım, soruları anlayan biri İngilizce'yi düzenleyebilir mi? – Zubair