freenode/lisp - IRC Chatlog
Search
23:00:15
slark
well in fact was thinking why should i return an expression to inc a variable when the inc could be done at expansion time
23:01:09
pjb
Because expansion time is normally done at compilation time, long before the values of the arguments are known.
10:20:06
phoe
|3b|: he wants efficience, I think destructive splitting of conses is going to be as efficient as he can get it
10:21:08
phoe
if you want programmer effiicience, alternatingly push into two lists, then nreverse them
10:21:39
|3b|
(loop for (a b) on (sort ...) by #'cddr collect a into as when b collect b into bs finally (return (list as bs)))
10:21:45
axion
Doesn't have to be 'fastest possible' but this will occur with every page load, so milliseconds count.
10:23:10
|3b|
even then, cache when they change rather than on access might win unless they changee more than they are read
10:23:11
jackdaniel
because it doesn't cons unnecessarily, doesn't reverse and keeps pointer to the list end
10:23:58
jackdaniel
oh, sorry, uiop:while-collecting does a lot of things, I'd go with cmuutil collect macro after all
10:24:22
|3b|
ACTION also notes that the performance loss from non-destructive split probably wouldn't show up on that page load anyway :p
10:25:52
phoe
my algorithm: grab references to 1st and 2nd cons of the list. set the CDR of the first cons to the 3rd cons, set the CDR of the first cons to the CDDDR of the first cons, set the CDR of the second cons to the CDDDR of the second cons. Use the CDRs of the first and second cons as the new values for the first and second cons, loop until the CDRs of the lists are NIL.
10:26:50
axion
The simplest code can be continually made 'fastest possible' over a lifetime for a programmer. I should have known better to phrase that a bit better
10:30:16
|3b|
loop/collect version sorts/splits the symbols from CL: in a little over 1.6 million cycles
10:33:12
axion
beach: So is a lot of things here, such as algorithm efficiency and Emacs buffer data structures being a bad data structure for their use :)
10:39:32
axion
I guess there's nothing wrong with it really. I just didn't expect a 2 element list of NIL's if given an initiallly empty list
10:40:26
axion
|3b|: What is the point of the WHEN clause? I don't see when it would change anything
10:47:15
axion
phoe's implementation is extremely fast, but I was expecting that keeping a reference to tail