assoc-if bug?

OpenLisp features, requests and ideas

assoc-if bug?

Postby dbane » Fri Nov 01, 2019 10:36 pm

I'm using OpenLisp 10.7.0. On macOS Catalina if that's relevant.

This works as expected:

Code: Select all
? (assoc 'b '((a . 1) (b . 2) (c . 3)))
;; elapsed time =  0.0000s, (0 gc).
= (b . 2)
?


However, this doesn't:

Code: Select all
? (assoc-if (lambda (key) (string= key "b")) '(("a" . 1) ("b" . 2) ("c" . 3)))
** <domain-error> : function 'string=' requires a <string> received 1.
?


Is the bug on my side or in OpenLisp?
dbane
 
Posts: 8
Joined: Wed Feb 23, 2005 6:42 pm
Location: Limerick, Ireland

Re: assoc-if bug?

Postby dbane » Fri Nov 01, 2019 11:20 pm

Just FYI, this is the behaviour I expected from reading the Reference Manual:

Code: Select all
(defun my-assoc-if (fn a-list)
  (if (null a-list)
    nil
    (let ((kv (car a-list)))
      (if (funcall fn (car kv))
        kv
        (my-assoc-if fn (cdr a-list))))))
dbane
 
Posts: 8
Joined: Wed Feb 23, 2005 6:42 pm
Location: Limerick, Ireland


Return to Request

Who is online

Users browsing this forum: No registered users and 2 guests

cron