Created
September 28, 2015 03:22
-
-
Save tim-br/299a40f983c674c1a306 to your computer and use it in GitHub Desktop.
scheme stuff
This file contains hidden or 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
#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