(define (divisible n k) (= 0 (mod n k)))
(define (divisible-by-list n l) (fold (lambda (k o) (or o (divisible n k))) #f l))
Name:
Anonymous2007-08-12 17:47 ID:Mvf+qhCr
(define (divisible n l)
(if (pair? l) #f
(if (= (mod n (car l)) 0) #t
(divisible n (cdr l)))))
(divisible n '(3 5))
Name:
Anonymous2007-08-12 18:05 ID:RyfBwU/E
>>3
ok this is neat
I think I want to generalize though
divisible = (lambda (n d) (= 0 (mod n d))
f-by-list = (lambda (n l) (fold (lambda (k o) (or o (f n k))) #f 1))
divisble-by-list = (lambda (n l) (fold (lambda (k o) (or o ((lambda (n d) (= 0 (mod n d)) n k))) #f 1))
((lambda (n l) (fold (lambda (k o) (or o ((lambda (n d) (= 0 (mod n d)) n k))) #f 1)) n '(3 5))
hmm
Name:
Anonymous2007-08-12 18:08 ID:UuB0Fh1x
LOL Lisp.
int f(n){(!(n%3) || !(n%5))}
Name:
Anonymous2007-08-12 18:19 ID:+1As6lo3
LOL De Morgan.
int f(n){!(n%3 && n%5)}
Name:
Anonymous2007-08-12 18:23 ID:UuB0Fh1x
>>7
LOL some sort of newfag college undergrad who just finished discrete math. My version is clearly more readable, hence it is superior to yours in every way possible.
Name:
Anonymous2007-08-12 18:38 ID:+1As6lo3
LOL hurt pride
Really, just use haskell for euler, you'll finish the first 50 or so in no time.
(defun any (&rest predicates)
(lambda (x)
(some (function identity)
(mapcar (function (lambda (p) (funcall p x))) predicates))))
did that so (any (% 3) (% 5)) makes just the function I needed,
can anyone beat that? I don't think so :p
Name:
Anonymous2007-08-13 3:12 ID:UK+mlIcu
>>15
This is what I love about you smug LISP weenies. Always making excuses for your failure of a language. Go count some parenthesis, I'm done talking with your stupid ass.
yeah i dont know lisp or anything but this thread is hilarious i mean what the fuck is >>21 even supposed to mean and how does it relate to finding if numbers are evenly divisible by 3 or 5
there are some functions explained in the book On Lisp exactly like the "all" and "any" you proposed. They're called fun (function union) and fint (function intersection).
Name:
Anonymous2007-08-13 7:30 ID:3J35KuIg
>>24
lmao, that wasn't actually the program but hehe
>>25
of course you don't understand it if you don't know lisp... duh..
>>42
you forgot the CAR CDR LAMBDA and )))))))))))))))))))))))))))
Name:
Anonymous2007-08-14 13:04 ID:4If5aQmY
You people obviously have no experience writing enterprise maintainable code. See the following short snippet for an elegant yet extendible solution in Java. Note how code encapsulation lets me reuse the subtle optimizations in new code. I plan to further generalize it by wrapping it all up with the singleton and factory patterns and allowing configuration via XML.
interface NumDivisor {
public boolean dividesNumber(int n);
}
code]o[/code] oo o o HOWoo o o o DOooo o o o o YOUoooo o o o o o FEELooooo o o o o ABOUToooo o o o BBCODE?ooo o o i like it!oo oo
Name:
Anonymous2013-08-31 20:10
You know who wasn't stupid? The guy who invented the pet rock.
Name:
Anonymous2013-08-31 20:12
>>1
what? that is perfect, you don't need anything else
everyone else in this thread is trolling you
Name:
Anonymous2013-08-31 21:40
I made a big mistake bringing Marisa with me. There aren't any partner spellcards on the floor (only in secret rooms, but I have found only one). I prepared her to do massive damage with spellcards, so she sucks at one-on-one battle.