Created
December 19, 2012 02:43
-
-
Save paultag/4333914 to your computer and use it in GitHub Desktop.
frickn' lisp in frickn' python
This file contains 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
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp | |
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all | |
; copyrightable. | |
(def hello "World!") | |
(def square (fn [arg] | |
(* arg arg))) | |
(def factorial (fn [n] | |
(if (<= n 1) | |
1 | |
(* n (factorial (- n 1)))))) | |
(def fib (fn [n] | |
(if (< n 2) | |
n | |
(+ (fib (- n 1)) (fib (- n 2)))))) |
This file contains 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
import hy.lang.importer | |
import really_lisp | |
print really_lisp.hello | |
# "World!" | |
print really_lisp.square(4) | |
# 16 | |
print really_lisp.factorial(10) | |
# 3628800 | |
print [really_lisp.fib(x) for x in range(1, 20)] | |
# [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, | |
# 233, 377, 610, 987, 1597, 2584, 4181] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment