[racket-users] assoc api

2016-02-10 Thread Brian Adkins
Is there an advantage to having assoc return the associated list vs. the tail of the associated list? Wouldn't it be better for it to behave more like hash-ref ? Do folks typically just define their own function such as the following ? (define daynums (map list '(sunday

Re: [racket-users] assoc api

2016-02-10 Thread Neil Van Dyke
It doesn't much matter how you do an alist lookup for most programs. Go ahead and learn and teach whatever makes most sense. But, for practical application, sometimes you have to implement, say, some large performance-sensitive graph algorithm, where even constant overhead factors can make a

Re: [racket-users] assoc api

2016-02-10 Thread Jon Zeppieri
On Wed, Feb 10, 2016 at 11:02 AM, Neil Van Dyke wrote: > For your example, more traditional would be `(map cons` and `cdr`. Then > it's more clear that `assoc` returning the matched pair lets you > distinguish a `#f` `cdr` in a match from no match found. > > And dict-ref

Re: [racket-users] assoc api

2016-02-10 Thread Jon Zeppieri
I don't know whether there's an advantage or not, but I can say that the behavior of assoc is inherited from Scheme and other Lisps. I usually want the behavior you describe, so I often use dict-ref with dealing with association lists. -Jon On Wed, Feb 10, 2016 at 10:55 AM, Brian Adkins

Re: [racket-users] assoc api

2016-02-10 Thread Neil Van Dyke
For your example, more traditional would be `(map cons` and `cdr`. Then it's more clear that `assoc` returning the matched pair lets you distinguish a `#f` `cdr` in a match from no match found. Neil V. -- You received this message because you are subscribed to the Google Groups "Racket