Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(doc-of file/read ) # => file/read docs are shown
(def tmpfile (file/temp ))
(doc-of (tmpfile :read )) # => also shows the file/read docs.
# Note that we didn't have to use the file/read symbol here to get docs. (def a @[])
(array/push a 1 ) # => @[1]
a # => @[1]
(array/push a 2 ) # => @[1 2]
a # => @[1 2]
(abstract? (file/temp )) # => true
(abstract? (int/s64 1 )) # => true
(map abstract? [ nil true 97 'a :a "a" ])
# => @[false false false false false false]
(map abstract? [ [97 ] @[97 ] {0 97 } @{0 97 } ])
# => @[false false false false]
(map abstract? [ even? loop file/open (fn []) ])
# => @[false false false false]
(map abstract? [ (file/temp ) (fiber/new (fn [])) ])
# => @[true false]
# Suppose you have a fiber that yields chunks of paginated api results:
(def api-results (fiber/new (fn [] (yield [1 2 3 ]) (yield [4 5 6 ]))))
# Using :iterate, the right side of the binding is evaluated each time the loop is run,
# which allows for running a side-effecting expression that may be different each time.
(loop [_ :iterate (fiber/can-resume? api-results )] (pp (resume api-results )))
# This example can be simplified using :generate
(loop [chunk :generate api-results ] (pp chunk ))
(def b @"" )
(xprint b "HOHOHO" )
# => nil
b
# => @"HOHOHO\n" (var x 5 )
(%= x 3 )
(pp x ) # 2 (when-with [f (file/open "nofile.exists" )]
(print "Realy?" ))
# it just returns nil (- )
# => 0 [1 2 3 ] # => (1 2 3)
(tuple/type [1 2 3 ]) # => :parens
(tuple/brackets 1 2 3 ) # => [1 2 3]
(tuple/type (tuple/brackets 1 2 3 )) # => :brackets
# `parse` can decode arbitrary JDN (Janet Data Notation) encoded by `string/format`
(def encoded (string/format "%j" @{:a 123 :b "foo" :c @{1 [1.2 2.3 3.4 ]}}))
# => "@{:a 123 :b \"foo\" :c @{1 @[1.2 2.2999999999999998 3.3999999999999999]}}"
(parse encoded )
# => @{:a 123 :b "foo" :c @{1 @[1.2 2.3 3.4]}} (in [10 11 12 13 ] 0 42 ) # => 10
(in {:a 10 :b 20 } :a 42 ) # => 10
(in [10 11 12 ] 99 42 ) # error
(in [10 11 12 ] -1 42 ) # error
(in [10 11 12 ] -2 42 ) # error
(in {:a 1 } :z 42 ) # => 42
(map (fn [x ] (in x 0 42 )) [ 'a :a "a" [97 ] @[97 ] {0 97 } @{0 97 } {:a 1 } ])
# => @[ 97 97 97 97 97 97 97 42 ]
(import spork/charts :as c )
(import spork/gfx2d :as g )
(g/save "bla.png" (c/plot-line-graph
:canvas (g/blank 100 100 )
:data {:timestamp [1 2 3 40 5 60 ]
:temperature-1 [75.1 75.2 75.4 75.5 75.5 75.4 ]
:temperature-2 [55.1 55.4 55.7 60.0 60.4 60.9 ]}
:x-column :timestamp
:y-column [:temperature-1 :temperature-2 ]))
# then you can look at bla.png (map number? [nil true 42 :a "a" [] {} (fn []) ])
# => @[false false true false false false false false ]
(reduce2 + [1 2 3 ]) # -> 6
(accumulate2 + [1 2 3 ]) # -> @[1 3 6] # https://en.wikipedia.org/wiki/Error_function
(math/erf 1 )
# => 0.842701