Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(get (os/environ ) "HOME" ) # => "/Users/cell"
(os/getenv "HOME" ) # => "/Users/cell"
(print
(prompt :a
(for i 0 1000000000000
(print (string "i=" i ))
(if (= i 2 )
(return :a 10 )))))
# output:
# i=0
# i=1
# i=2
# 10 (let [a 1 b 2 c 3 ] (+ a b c )) # => 6
(let
[a 1
b (+ a 1 )
c (+ b 1 )]
(+ a b c )) # => 6
# janet 1.10.1
# note that os/cd does not appear to update PWD in the shell's environment.
(os/cwd ) # => "/Users/cell/tmp"
(os/getenv "PWD" ) # => "/Users/cell/tmp"
(os/cd "/tmp" ) # => nil
(os/cwd ) # => "/private/tmp" (on Apple, /tmp is actually /private/tmp)
(os/getenv "PWD" ) # => "/Users/cell/tmp"
(get default-peg-grammar :a+ )
# => '(some :a)
(zipcoll [:a :b :c ] [1 2 3 ]) #=> @{:c 3 :a 1 :b 2} (next [4 5 6 ] ) # => 0
(next [4 5 6 ] 0 ) # => 1
(next [4 5 6 ] 1 ) # => 2
(next [4 5 6 ] 2 ) # => nil
# note that dictionary keys are not necessarily in the same order
# as the corresponding literal.
(next {:a 5 :b 6 :c 7 } ) # => :a
(next {:a 5 :b 6 :c 7 } :a ) # => :c
(next {:a 5 :b 6 :c 7 } :c ) # => :b
(next {:a 5 :b 6 :c 7 } :b ) # => nil
(last :hello )
# => 111
(math/hypot 5 12 )
# => 13 # uses the fn shorthand
(take-until |(< 3 $ ) [0 1 2 3 4 5 6 7 8 ])
# (0 1 2 3)
# uses partial
(take-until (partial < 3 ) [0 1 2 3 4 5 6 7 8 ])
# (0 1 2 3) (defn walker
`Simple walker function, that prints non-sequential
members of the form or prints "Sequence" and walks
recursively sequential members of the tree.`
[form ]
(if (or (indexed? form ) (dictionary? form ))
(do (print "Sequence" )
(walk walker form ))
(print form )))
(walk walker [[[[0 1 3 ]] 16 7 [3 [3 5 ]] 3 4 ] 1 [3 4 ]])
# Prints
# Sequence
# Sequence
# Sequence
# 0
# 1
# 3
# 16
# 7
# Sequence
# 3
# Sequence
# 3
# 5
# 3
# 4
# 1
# Sequence
# 3
# 4
(array/slice [1 2 3 ])
#=> @[1 2 3]
# good way to convert tuple to array (def a-tuple-1 [:number 10 ])
(def a-tuple-2 [:string "Hello there!" ])
(defn show [what ]
(match what
[:number n ] (printf "It's a number! %d" n )
[:string s ] (printf "Here's a string: %s" s )
_ (printf "I dunno what this is: %q" what )))
(show a-tuple-1 )
(show a-tuple-2 )
(show [:array @[]])(mod 13 5 ) # 3 (let [a 1 ]
(let [b a ]
b )) # => 1