Skip to content

Instantly share code, notes, and snippets.

@dmastylo
Created April 3, 2014 20:44
Show Gist options
  • Save dmastylo/9962508 to your computer and use it in GitHub Desktop.
Save dmastylo/9962508 to your computer and use it in GitHub Desktop.
(define (addToStack expr extra_arg)
(cons expr extra_arg)
)
(define (popStack extra_arg)
(cond ( (null? (car extra_arg)) '() )
( else (cdr extra_arg) )
)
)
(define (findInStack symbol extra_arg)
(cond ( (null? extra_arg) '() )
( (null? (car extra_arg)) '() )
( (equal? symbol (car (car extra_arg))) (cdr (car extra_arg)) )
( else (if (null? (cdr extra_arg)) #f
(findInStack symbol (cdr extra_arg)) )
)
)
)
(define (inStack? symbol extra_arg)
(cond ( (null? extra_arg) #f )
( (null? (car extra_arg)) #f )
( (equal? symbol (car (car extra_arg))) #t )
( else (if (null? (cdr extra_arg)) #f
(inStack? symbol (cdr extra_arg)) )
)
)
)
(addToStack '(myadd 4 5) '())
;(addToStack '(a 10) '())
(inStack? 'l (addToStack '(a 10) '((b 15) (c 20) (z -5) (n 42) (a 20)) )
)
;(popStack (addToStack '(a 10) '((b 15) (c 20) (z -5) (n 42) (a 20)) ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment