Skip to content

Instantly share code, notes, and snippets.

@Glorp
Created June 9, 2019 09:59
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 Glorp/979b7c23b7e650f45fb7372671bc5f8c to your computer and use it in GitHub Desktop.
Save Glorp/979b7c23b7e650f45fb7372671bc5f8c to your computer and use it in GitHub Desktop.
#lang lazy
; put racket instead of lazy in the line above to make it less lazy
(struct zero () #:transparent)
(struct succ (pred) #:transparent)
(define one (succ (zero)))
(define two (succ one))
(define (inf) (succ (inf)))
(define (<= a b)
(cond
[(zero? a) #t]
[(zero? b) #f]
[else (<= (succ-pred a) (succ-pred b))]))
#|
can try these in the REPL...
(<= one two)
(<= two one)
(<= two (inf))
(<= (inf) two)
(<= (inf) (inf))
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment