Contents    Page-10    Prev    Next    Page+10    Index   

doseq and sort

doseq is a convenient looping function to do the same thing for every element of a list:


user=> (doseq [item '(a b c)]
         (println "item = " item))
item =  a
item =  b
item =  c
nil          ; value of doseq

There is a convenient sort function that makes a sorted version of a list (nondestructive):


user=> (let [ lst    '(z a p)
              sorted (sort lst) ]
         (list lst sorted) )

((z a p) (a p z))