Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Divisible by 3 or 5, in lisp

Name: Anonymous 2007-08-12 17:20 ID:RyfBwU/E

(lambda (n) (or (= 0 (mod n 3)) (= 0 (mod n 5))))

how on earth do you write this in lisp, I mean better than I have here.. surely it must be possible?

Rube Goldberg devices are definitely acceptable if it makes the final code better.. hope you have some ideas /prog/

Name: Anonymous 2007-08-13 0:18 ID:WEd4ro21

>>16
>>4
or something like
(defun f (n l) (find-if (p/ divisible n) l)
if you use the ugly p/ macro I made.
so you call it like this:

(f 1 '(3 5))
or
(f n '(3 5 7 11))
or any list you want. the exact example you asked for:

(lambda (n) (find-if (p/ divisible n) '(3 5)))
without the macro, in plain lisp
(lambda (n) (find-if (lambda (k) (divisible n k)) '(3 5)))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List