Skip to content

Instantly share code, notes, and snippets.

@sudoankit
Last active February 14, 2019 10:32
Show Gist options
  • Save sudoankit/c6af70354d5cf85873e02b8e5e7737c6 to your computer and use it in GitHub Desktop.
Save sudoankit/c6af70354d5cf85873e02b8e5e7737c6 to your computer and use it in GitHub Desktop.
Exercise 1.1 of SICP
MIT/GNU Scheme running under OS X
Copyright (C) 2014 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Friday September 28, 2018 at 5:08:35 PM
Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/C 4.118
Edwin 3.116
1 ]=> ;; Exercise 1.1 of SICP. 14th Feb, 2019.
1 ]=> 2
;Value: 2
1 ]=> 10
;Value: 10
1 ]=> (+ 2 3 4)
;Value: 9
1 ]=> (+ 5 3 4)
;Value: 12
1 ]=> (- 9 1)
;Value: 8
1 ]=> (- 9 10)
;Value: -1
1 ]=> (/ 6 2)
;Value: 3
1 ]=> (+ (* 2 4 ) ( - 4 6 ) )
;Value: 6
1 ]=> (define a 3)
;Value: a
1 ]=> (define b (+ a 1))
;Value: b
1 ]=> (+ a b ( * a b))
;Value: 19
1 ]=> (= a b )
;Value: #f
1 ]=> (if (and (> b a) (< b (* a b)))
b
a)
;Value: 4
1 ]=> (and (> b a) (< b (* a b)) )
;Value: #t
1 ]=> (cond (( = a 4 ) 6) ;; a is 3
(( = b 4 ) (+ 6 7 a))
(else 25))
;Value: 16
1 ]=> ( + 2 (if (> b a) b a))
;Value: 6
1 ]=> (* (cond ((> a b) a)
((< a b) b)
(else -1))
(+ a 1))
;Value: 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment