libera/#commonlisp - IRC Chatlog
Search
17:12:05
Bike
you apparently want the direct slot definitions that were merged into that effective definition?
17:12:25
Bike
usually what you do is define your own slot-definition classes, and just put whatever information you need in a slot of the effective slot definition
17:13:10
Bike
you can define a method on compute-effective-slot-definition to define how whatever information you want is merged from the inheritance
17:18:57
hhdave
Bike: ok. Putting the extra info into the slot-definition subclasses might be sensible. I'll get back to it next week. I have subclassed these slot definition classes. Thanks.
21:52:37
phoe
I have a list of numbers and I want to get a list of their sub-sums, so e.g. (1 2 3 4 5 ...) -> (1 3 6 10 15 ...)
21:54:25
moon-child
that's a prefix scan, which is a variant of reduce. I don't know of a specific implementation strategy, but you can use that keyword to search for one
21:55:43
jcowan
the nice thing about reduce over fold is that if you know the procedure is associative you can use a parallel algorithm.
22:01:16
edgar-rft
(let ((sum 0)) (mapcar (lambda (x) (incf sum x)) (list 1 2 3 4 5))) => (1 3 6 10 15)
22:04:11
edgar-rft
but code that I still can understand at the first read in hundred years from now...
22:48:30
jcowan
moon-child: No. The main difference is that you fold using a plain function and you reduce using a monoid.
22:49:48
jcowan
In a monoid, you always statically know the start value, instead of it being passed to the fold: thus the normal + monoid returns 0 if applied to zero arguments. Third, fold can be done in parallel because a monoid is guaranteed to be associative.
1:20:03
pjb
phoe: (mapcar (let ((s 0)) (lambda (i) (incf s i))) (iota 10)) #| --> (0 1 3 6 10 15 21 28 36 45) |#
1:26:29
moon-child
(actually, I would have expected the former to perform better, but sbcl seems to generate the same code for both)
1:32:14
pjb
If you look at the code of the minimal-compiler, (or just compiler), it would be obvious why the same is generated.