Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ______ ______ __ __
- # /\ __ \ /\ ___\ /\ \_\ \
- # \ \ __ \\ \___ \\ \ __ \
- # \ \_\ \_\\/\_____\\ \_\ \_\
- # \/_/\/_/ \/_____/ \/_/\/_/
- # ─────────────────────────────────────────
- # Literal Values
- # ─────────────────────────────────────────
- # Numbers
- 1
- 2.71828
- # Strings
- "Hello World"
- "Ready\nSet\nGo"
- # Bools
- true
- false
- # ─────────────────────────────────────────
- # Lists
- # ─────────────────────────────────────────
- # Creating Lists
- (list 1 2 3)
- (list 42 "Corge" true)
- (list 9 (list 10 11 12) 13)
- # Count
- (count (list 1 2 3))
- # Map
- (let add-one
- (lambda (x) (+ x 1)))
- (map add-one (list 1 2 3))
- # First
- (first (list 9 8 7))
- # Last
- (last (list 9 8 7))
- # ─────────────────────────────────────────
- # Comparison and Equality Operations
- # ─────────────────────────────────────────
- (> 10 5)
- (< 5 10)
- (= 1 1)
- # ─────────────────────────────────────────
- # Arithmetic Operations
- # ─────────────────────────────────────────
- (+ 1.1 1.1)
- (- 3 2)
- (* 4 5)
- (/ 10 2)
- (% 2 3)
- # ─────────────────────────────────────────
- # Let
- # ─────────────────────────────────────────
- (let a 1)
- (let b "Hello World")
- (let c true)
- # ─────────────────────────────────────────
- # Functions
- # ─────────────────────────────────────────
- (lambda (x) (x))
- (λ (x)
- (let a 1)
- (let b 2)
- (+ x (+ a b)))
- (let square (lambda (x) (* x x)))
- # ─────────────────────────────────────────
- # Conditionals
- # ─────────────────────────────────────────
- (if (> 1 2) "A" "B")
- (if (= a 1) "X" true)
- # ─────────────────────────────────────────
- # Console I/O
- # ─────────────────────────────────────────
- # Input
- (let name
- (input "What is your name?"))
- # Print
- (print "Hi " name "!")
- (print
- "West of House\n"
- "This is an open field west of a white house, with a boarded front "
- "door.\n"
- "There is a small mailbox here.\n"
- "A rubber mat saying 'Welcome to Zork!' lies by the door.")
- (print (list 1 2 3))
- (print true)
- (print (lambda (x) (x)))
- # ─────────────────────────────────────────
- # Random Numbers
- # ─────────────────────────────────────────
- # Generate a random number between 0 and 1
- (let x (random))
- # ─────────────────────────────────────────
- # Working With Strings
- # ─────────────────────────────────────────
- (print (string-replace "The quick brown fox" "brown" "red"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement