libera/#lisp - IRC Chatlog
Search
13:14:53
mdhughes_
(define (minus . rest) (fold mm (if (null? (cdr rest)) 0 (car rest)) (if (null? (cdr rest)) rest (cdr rest))))
13:16:23
mdhughes_
Makes sense if you're using cons or other things that take the accumulator right, but it's nonsensical in math.
13:23:49
jcowan
(btw, neither left nor right fold, neither accumulator-first nor accumulator-second, will allow you to correctly implement - as a fold)
13:26:05
jcowan
As a result of historical factors, vector-like SRFIs use the accumulator-first style and all other sequence SRFIs use the accumulator-second style.
13:26:48
jcowan
A good approach for Committee C to clean this up, IMAO, is to use the names fold and fold-right for accumulator-second (SRFI 1) style and the names lfold and rfold for accumulator-first style.
13:30:51
jcowan
Nope. Try the four cases for yourself on lists of one, two, and three values. None of them produce the right answer always.
13:40:38
jcowan
sorry, screwed up both pastes: you need to prepend (define a '(1)) and (define (s- x y) (- y x))
13:41:14
jcowan
in any case, your `minus` function does what I said needs to be done: it special-cases the unary version.
13:42:11
jcowan
irritating: -adic fails for "monadic" (you need "unary"), but -ary fails for "variary" (you need "variadic").
14:58:27
sham1
Well, monadic does work. After all, the APL people seem to be just fine using that word. Same with dyadic, triadic and so on.
15:26:55
jcowan
If you speak of "monadic functions" out of context, though, you'll probably get a WHUT.
23:21:01
White_Flame
prokhor__: from what I'm getting into, I believe the "Building Large Knowledge-Based Systems" book linked is old enough to not represent how cyc works anymore. they specifically got rid of frame representation and went with 100% logic statements