Skip to content

Instantly share code, notes, and snippets.

@oubiwann
Last active December 7, 2016 14:53
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 oubiwann/f6871f4fdeac7d8fc8b88a7874683a00 to your computer and use it in GitHub Desktop.
Save oubiwann/f6871f4fdeac7d8fc8b88a7874683a00 to your computer and use it in GitHub Desktop.
LFE Winter Wonderland
;; Start an LFE REPL:
;;
;; $ lfe
;;
;; Load the file:
;;
;; lfe> (run "winter-wonderland.lfe")
;;
;; Then run these:
;;
;; (In the meadow we can build a snowman)
;; (Then pretend that he is Parson Brown)
;; (He'll say are you married?)
;; (We'll say no man)
;; (But you can do the job)
;; (When you're in town)
(set notes '("\x266A;" "\x266B;" "\x1F39C;" "\x1F39D;" "\x1F3B5;" "\x1F3B6;"))
(set notes-len (length notes))
(defun get-note ()
(clj:-> notes-len
(random:uniform)
(lists:nth notes)))
(defun append-note (_ acc)
(clj:->> (get-note)
(list)
(lists:append `(,acc " "))))
(defun get-notes ()
(clj:->> notes-len
(random:uniform)
(lists:seq 1)
(lists:foldl #'append-note/2 "")))
(defun print-notes ()
(clj:->> (get-notes)
(list)
(io:format "~ts~n ")))
(defmacro In _ `(print-notes))
(defmacro Then _ `(print-notes))
(defmacro He'll _ `(print-notes))
(defmacro We'll _ `(print-notes))
(defmacro But _ `(print-notes))
(defmacro When _ `(print-notes))
(set word-list '(the meadow we can build a snowman
pretend that he is Parson Brown
say are you married?
no man
do job
in town))
(defun get-sets ()
(lists:foreach
(lambda (var)
`(set ,var 1))
word-list))
(defmacro set-vars ()
(progn ,@(get-sets)))
(defun loaded-winter-wonderland ()
'ok)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment