Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gautham Velchuru
341_final
Commits
75ff4b4e
Commit
75ff4b4e
authored
Jun 05, 2018
by
Gautham Velchuru
Browse files
racket lambdas
parent
7efffd97
Changes
1
Hide whitespace changes
Inline
Side-by-side
all_study_guide.tex
View file @
75ff4b4e
...
...
@@ -155,7 +155,19 @@ We can navigate these with car for first element, cdr for tail, cadr for head of
\subsubsection
{
Properties
}
Structs in Racket, like objects in OOP, are pass-by-pointer -- so, (if they are mutable), we can set their fields
but when we reassign the original struct is unchanged.
\subsection
{
Lambdas
}
Lambdas are good not only for delaying evaluation and implementing lexical closures, but
also because you can use them to do multiple things in a row.
\\
Question: Write a function map-pairs that takes in a function and a list of kvpairs and mutates
the pairs such that the new value for each pair is the function applied to their original
values.
\begin{minted}
(define (map-pairs f ls)
(if (null? ls)
'()
((lambda () (set-kvpair-value! (car ls) (f (kvpair-value (car ls)))) (map-pairs f (cdr ls))))))
\end{minted}
\section
{
Prolog
}
\subsection
{
Rules, facts, and goals
}
A fact is a predicate, and a rule is an extension of a fact with added clauses:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment