Skip to content

Commit

Permalink
Merge pull request #8 from jrincayc/example_and_ref_work
Browse files Browse the repository at this point in the history
Example and ref work
  • Loading branch information
jrincayc authored Aug 7, 2022
2 parents 2283b93 + 2119b7a commit 21dbeef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bib.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
\bibitem{SICP}
Harold Abelson and Gerald Jay Sussman with Julie Sussman.
{\em Structure and Interpretation of Computer Programs, second edition.}
MIT Press, Cambridge, 1996.
MIT Press, Cambridge, \url{https://mitpress.mit.edu/sites/default/files/sicp/index.html}, 1996.

%\bibitem{Bawden88}
%Alan Bawden and Jonathan Rees.
Expand Down
19 changes: 18 additions & 1 deletion example.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(append '(a b) '(c d)) \ev (a b c d)
\end{scheme}

This procedure returns the first sublist of {\em l} whose car is {\em obj}.
This procedure returns the first sublist of {\em l} whose car is symbol {\em obj}.

\begin{scheme}
(define assq (lambda (obj l)
Expand All @@ -42,6 +42,23 @@
(assq 'd e) \ev \schfalse
\end{scheme}

This procedure returns the first sublist of {\em l} whose car is symbol or number {\em obj}.

\begin{scheme}
(define assocns (lambda (obj l)
(cond ((null? l) \schfalse)
((and (number? obj) (number? (car (car l)))
(= obj (car (car l))))
(car l))
((eq? obj (car (car l))) (car l))
(else (assocns obj (cdr l)))
)))
(define e2 '((a 1) (3 b) (c 4)))
(assocns 'a e2) \ev (a 1)
(assocns 3 e2) \ev (3 b)
(assocns 1 e2) \ev \schfalse
\end{scheme}

This shows using the Y combinator to create a recursive function.

\begin{scheme}
Expand Down

0 comments on commit 21dbeef

Please sign in to comment.