I am trying to use assoc in racket to create a memo table and want to associate an ordered pair (x,y) with a value but I am a little unclear of the syntax.
For example I have:
[f (lambda (x y)
(let ([ans (assoc [x y] memo)])
But it is not correct.
The
assocprocedure receives as its first parameter the “key” to the element that you’re looking for, and as second parameter a list of associations – in this context, an association is just a key-value pair. It will return the first association that corresponds to the given key or#fif none was found. For example:If you need to use pairs as keys, that’s fine and it will work like this: