Skip to content

Instantly share code, notes, and snippets.

@tim-br
Created September 28, 2015 03:22
Show Gist options
  • Save tim-br/299a40f983c674c1a306 to your computer and use it in GitHub Desktop.
Save tim-br/299a40f983c674c1a306 to your computer and use it in GitHub Desktop.
scheme stuff
#lang racket
(define (atom? item)
(not (pair? item)))
(define (numbered? aexp)
(cond [(atom? aexp) (number? aexp)]
[else
(and (numbered? (car aexp))
(numbered? (car (cdr (cdr aexp)))))]))
(define (value nexp)
(cond [(atom? nexp) nexp]
[(eq? (car nexp) '+)
(+ (value (car (cdr nexp)))
(value (cdr nexp)))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment