123456789101112131415161718192021222324252627282930313233343536373839 |
- (define defn (macro (name params & body)
- `(define ,name (lambda ,params ,@body))))
- (define defmacro (macro (name params & body)
- `(define ,name (macro ,params ,@body))))
- (defn id (x)
- "This is the identity function, it returns its argument"
- x)
- (defn not (x)
- (if x #f #t))
- (defn false? (x)
- (not (true? x)))
- (defn zero? (x)
- (if (== x 0) #t (== x 0.0)))
- (defmacro apply (fn xs)
- `(,fn ,@,xs))
- (defn inc (x)
- (+ x 1))
- (defn dec (x)
- (- x 1))
- (println "prelude loaded!")
- ; assertions from here on
- (assert (not (not #t)))
- (assert (not #f))
- (assert (zero? 0))
- (assert (zero? 0.0))
- (assert ((lambda (x) x) #t))
- (assert (true? #t))
- (assert (false? #f))
|