Created
March 18, 2019 14:24
-
-
Save kkestell/850b54c7f75588c7c5b1fb65d16b898c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ______ ______ __ __ | |
# /\ __ \ /\ ___\ /\ \_\ \ | |
# \ \ __ \\ \___ \\ \ __ \ | |
# \ \_\ \_\\/\_____\\ \_\ \_\ | |
# \/_/\/_/ \/_____/ \/_/\/_/ | |
# ───────────────────────────────────────── | |
# 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 "Hi " name "!") | |
"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")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment