Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

maps

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (let [z 1
         b 2 
         a 3]
   (def demokeys (sorted-map "z" z "b" b "a" a))
   (println demokeys)))
(example)

Execute Clojure Online

(ns clojure.examples.hello
	(:gen-class))

(defn hello-world [username]
(println (format "Hello, %s" username)))

(hello-world "world")

(defn addition [x]
(println (+ x, 4)))

(addition 2)

(defn testIf [y]
(if (> y 2)
  (println "joe")
  (println "king")))
  
(testIf 1)

(defn tesLlist  [coll ] 
 (println (reduce + coll )))
 

Execute Clojure Online

(ns clojure.examples.hello
	(:gen-class))

(defn hello-world [username]
(println (format "Hello, %s" username)))
(defn dziel-przez-zero [] (println (/ 1 0.0)))

(hello-world "world")
(dziel-przez-zero)
(println *e)

; nowy zbiór
(def visitors-old (atom #{}))
(swap! visitors-old conj "Janku")
(println (deref visitors-old))

(def visitors (atom #{}))
(defn hello 
    "Wywietla powitanie na wyjciu, uzywajac nazwy uzytkownika.
    Potrafi stwierdzi, e korzysta juz z programu."
    [username]
    (swap! visitors conj username)
    (println (str "Witaj, " username))
)

(hello "Marku")
(hello "Pawle")
(hello "Jurny")

AoC/2017/1

(ns clojure.examples.hello
	(:gen-class))
	
(require '[clojure.string :as str])

(defn uno [s]
    (let [l (map read-string (str/split s #""))]
    (apply + (keep-indexed #(if (= (nth l (mod (inc %1) (count l))) %2) %2) l))))

(defn duo [s]
    (let [l (map read-string (str/split s #""))]
    (apply + (keep-indexed #(if (= (nth l (mod (+ %1 (/ (count l) 2)) (count l))) %2) %2) l))))
    
(println (uno (read-line)))

Execute Clojure Online

(ns clojure.examples.hello
	(:gen-class))

(defn getIntegral [fun h]
    (def memFun
    (memoize (fn [x]
    ;(print ".")
    (if (< x 0)
        0
    (+ (memFun (- x h)) (* (fun x) h)))))))

(defn fun [x]
    x)

(def getInt (getIntegral fun 0.05))
(println (getInt 10))
(println (getInt 9.9))

Execute Clojure Online

(ns clojure.examples.hello
	(:gen-class))

(defn getIntegral [fun h]
    (def memFun
    (memoize (fn [x]
    ;(print ".")
    (if (< x 0)
        0
    (+ (memFun (- x h)) (* (fun x) h)))))))

(defn fun [x]
    x)

(def getInt (getIntegral fun 0.2))
(println (getInt 10))
(println (getInt 9.9))

Execute Clojure Online

    //Word length and letters list
   def main(args: Array[String]) {
        
        def printAllCombos(letters: List[Char]) = {
            
        }
        
        def getWords(numbers: List[Int]) = {
            var letters: List[List[String]] = List()
            for (num <- numbers) { //loop for length of list and append values
                letters = num match {
                    case 0  => List("0") :: letters
                    case 1  => List("1") :: letters
                    case 2  => List("A", "B", "C") :: letters
                    case 3  => List("D", "E", "F") :: letters
                    case 4  => List("G", "H", "I") :: letters
                    case 5  => List("J", "K", "L") :: letters
                    case 6  => List("M", "N", "O") :: letters
                    case 7  => List("P", "Q", "R", "S") :: letters
                    case 8  => List("T", "U", "V") :: letters
                    case 9  => List("W", "X", "Y", "Z") :: letters
                }
            }
            letters = letters.reverse
        }
        getWords(List(2, 4))
        
   }

Execute Clojure Online

(ns clojure.examples.hello
	(:gen-class))

(defn hello-world [username]
(println (format "Hello, %s" username)))

(hello-world "world")

java

(ns Project
   (:gen-class))
(defn Example []
   (println (.tolowerCase "Hello World")))
(Example)

Clojure stuff

(ns lispjunk
;    (:use java.base)
    )

    (def c 0)
    (def total 0)

    (doseq [arg *command-line-args*]
        (def arg-val (int (read-string (str "0" arg)) ) )
        (printf "arg='%s' > %s\n" arg arg-val)
        (def total (+ total arg-val) )
    )

    (println "----")
    (println (format "args = %d" (count *command-line-args*)) )
    (println (format "total = %d" total) )
    (println "----")
    
    (def c 32)
    (while (< c 128)
        (print (char c))
        (def c (+ c 1))
        (if (= (mod c 32) 0)
            (println) )
    )
    

1 2 3 4 5 6 7 ... 20 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.