Skip to content

Instantly share code, notes, and snippets.

@paultag
Created December 19, 2012 02:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paultag/4333914 to your computer and use it in GitHub Desktop.
Save paultag/4333914 to your computer and use it in GitHub Desktop.
frickn' lisp in frickn' python
; 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))))))
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