Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(one? (math/next 1 math/inf )) # => false # Run this in a file.
# Notice how each thread gets its own copy of the environment,
# including the global 'counter' variable.
(var counter 0 )
(defn start-thread [name sleep ]
(def chan (ev/thread-chan ))
(ev/spawn-thread
(repeat 10
(ev/sleep sleep )
(++ counter )
(print name " counter is " counter ))
(print name " has finished" )
(ev/give chan "done" ))
chan )
# Spawn two threads that increment counter
(def chan-a (start-thread "Slow thread" 0.8 ))
(def chan-b (start-thread "Fast thread" 0.45 ))
# Wait for both threads to finish
(ev/take chan-a )
(ev/take chan-b )
(print "Global counter is still " counter )(def a @[1 2 ])
(array/concat a 3 [4 5 ] @[6 7 ] [] @[] 8 )
a # => @[1 2 3 4 5 6 7 8]
# sh/$'s contents are quasiquoted, allowing direct or string arguments
# so you need to unquote , variables:
(def out (file/open "trust-db.txt" :w ))
(sh/$ "gpg" "--export-ownertrust" > ,out ) # > requires an opened file object
(file/close out )
# note how > requires an opened file object
(with [out (file/open "trust-db.txt" :w )]
(sh/$ gpg --export-ownertrust > ,out ))(os/lstat "t.janet" )
# @{:size 249 :permissions "rw-r--r--" :nlink 1 :blocks 8 :dev 16777221 :accessed 1606236760 :modified 1606236759 :uid 501 :mode :file :blocksize 4096 :changed 1606236759 :inode 14801850 :rdev 0 :int-permissions 420 :gid 501}
(get (os/lstat "t.janet" ) :size ) # 249 (bnot 255 ) # => -256
(not= [1 1 ] [1 1 ]) # => false
(not= [1 1 ] [2 3 ]) # => true
(not= [1 1 ] @[1 1 ]) # => true
(not= [1 1 ] @[2 3 ]) # => true
(not= @[1 1 ] @[1 1 ]) # => true
(not= @[1 1 ] @[2 3 ]) # => true
(deep-not= [1 1 ] [1 1 ]) # => nil
(deep-not= [1 1 ] [2 3 ]) # => true
(deep-not= [1 1 ] @[1 1 ]) # => true
(deep-not= [1 1 ] @[2 3 ]) # => true
(deep-not= @[1 1 ] @[1 1 ]) # => nil
(deep-not= @[1 1 ] @[2 3 ]) # => true (sorted [1 -2 2 3 9 -10 ]) # @[-10 -2 1 2 3 9] (string? "hello" ) # => true
(string? @"hello" ) # => false
(string? :hello ) # => false
(invert {:a 1 :b 2 :c 3 })
# => @{3 :c 1 :a 2 :b} (var buf @"" )
(buffer/push-word buf 2147483647 )
(+
(get buf 0 ) # byte 1
(blshift (get buf 1 ) 8 ) # byte 2
(blshift (get buf 2 ) 16 ) # byte 3
(blshift (get buf 3 ) 24 )) # byte 4
# => 2147483647
(get default-peg-grammar :h )
# => '(range "09" "af" "AF") (take 2 [1 -2 2 3 9 -10 ]) # (1 -2) (repeat 3 (print "HO" ))
# => prints
# HO
# HO
# HO
(<= 1 2 3 ) # => true
(<= 1 2 1 ) # => false