Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created January 5, 2023 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdesl/8ea10d3a4abcb640c262ee03fbad5594 to your computer and use it in GitHub Desktop.
Save mattdesl/8ea10d3a4abcb640c262ee03fbad5594 to your computer and use it in GitHub Desktop.
; a function in scope
(fn square (x) (* x x))
; anon/lambda function
((fn (x) (* x x)) 3) ; 9
; variables
(var square2 4)
; let scoping
(let (
(x 50)
(y (* 2 x))
) (print x y)) ; prints 50 100
; some builtins, logic, booleans
(and (= (math/floor 3.14) 3) (> 5 2)) ; true
; while loops
(var i 0)
(while (< i 10) (do
(print i)
(set i (+ 1 i))
))
; string concat and printing
(var str (.. "hello " "world"))
(print str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment