<thuna`>
Nevermind, it's MAPL/MAPLIST, although that does mean not using LOOP
<hayley>
Not ,(loop for x on '(1 2 3) collect x)?
<ixelp>
(loop for x on '(1 2 3) collect x) => ((1 2 3) (2 3) (3))
<mfiano>
'reverse' is not well-defined. The output list reversed?
<thuna`>
No, I need it to be ((1) (1 2) (1 2 3))
<thuna`>
Sorry, I guess it was kind of ambiguous
<hayley>
,(reverse (loop for x on '(1 2 3) by #'butlast collect x))
<ixelp>
(reverse (loop for x on '(1 2 3) by #'butlast collect x)) => ((1) (1 2) (1 2 3))
<thuna`>
hayley: The goal is (loop for x on '(1 2 3) by #'something ... do some important stuff)
<thuna`>
The :COLLECT was just to show what I wanted X to be at each iteration
<hayley>
I don't think you can write SOMETHING (easily), as it needs to add values from the list which aren't in X.
<mfiano>
Well easy would be (loop for x on '(1 2 3) by #'butlast :collect x :into result :finally (return (nreverse result)))
<mfiano>
,(loop for x on '(1 2 3) by #'butlast :collect x :into result :finally (return (nreverse result)))
<ixelp>
(loop for x on '(1 2 3) by #'butlast :collect x :into result :finally (return (nreverse result))) => ((1) (1 2) (1 2 3))
<thuna`>
mfiano: You can't pack additional LOOP directives with that approach, unless you are doing the equivalent of (loop for x in (maplist 'identity '(1 2 3)) ... important stuff)
`Pixel_Outlaw has quit [Quit: Leaving]
<thuna`>
Wait... MAPLIST doesn't do what I want, why did I think it did?
<thuna`>
Disregard
dra has quit [Ping timeout: 264 seconds]
<mfiano>
The act of just invoking butlast once if not keeping a pointer is bad. Doing this in a loop is worse. Doing the additional linear access and then reversing, which may be optimal in-place, is...again...not the best. There are ways to do this better, but if you ever need to use #'last or #'butlast or similar, you really should be rethinking how your data got to that part of the program.
<mfiano>
Unless this is all macroexpansion time stuff, but still could be broken up into more appropriate functions.
<thuna`>
I don't expect the length of the given list to be more than 5 typically, so it's not that detrimental, but you're right, it's probably better to just refactor the thing a bit
Pixel_Outlaw has quit [Remote host closed the connection]
Pixel_Outlaw has joined #commonlisp
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 272 seconds]
mulk has quit [Ping timeout: 264 seconds]
Lord_of_Life_ is now known as Lord_of_Life
mulk has joined #commonlisp
ymir has quit [Ping timeout: 255 seconds]
igemnace has joined #commonlisp
Jach has quit [Quit: Leaving.]
<mfiano>
By the way, map-product is very similar to what you're after, with that one example anyway
<thuna`>
map-product?
ymir has joined #commonlisp
<mfiano>
(loop for x on '(1 2 3) by #'butlast :collect x :into result :finally (return (nreverse result))) ; => ((1) (2 1) (3 2 1))
pranavats has left #commonlisp [Disconnected: Replaced by new connection]
pranavats has joined #commonlisp
attila_lendvai_ has joined #commonlisp
cstml has joined #commonlisp
ymir has quit [Ping timeout: 246 seconds]
hayley has joined #commonlisp
epony has joined #commonlisp
rgherdt has joined #commonlisp
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
msv has quit [Remote host closed the connection]
mgl has joined #commonlisp
dino__ has joined #commonlisp
shka has joined #commonlisp
synchromesh has joined #commonlisp
synchromesh has quit [Client Quit]
danse-nr3 has joined #commonlisp
danse-nr3 has quit [Remote host closed the connection]
danse-nr3 has joined #commonlisp
dcb has quit [Quit: Connection closed for inactivity]
dino__ has quit [Ping timeout: 256 seconds]
cstml has quit [Ping timeout: 255 seconds]
rgherdt has quit [Remote host closed the connection]
rgherdt has joined #commonlisp
epony has quit [Remote host closed the connection]
epony has joined #commonlisp
donleo has joined #commonlisp
Odin-LAP has quit [Ping timeout: 252 seconds]
traidare has joined #commonlisp
<semz>
Why does LOOP not allow termination tests before variable clauses? Is this just a spec oversight or is there a reasonable implementation of LOOP that wouldn't be able to handle that?
varjag has joined #commonlisp
<semz>
(I'm aware that most LOOP impls support this as an extension)
<beach>
Actually, it may allow it. There is a phrase indicating that in the standard. But that phrase is not reflected in the grammar.
<beach>
"Termination-test control constructs can be used anywhere within the loop body."
<semz>
hm
<semz>
Does "loop body" have an explicit definition? I could see variable clauses being considered part of some kind of "preamble"
<semz>
"The termination tests are used in the order in which they appear." might also clash with whether loop variables are rebound or reassigned on each iteration
<beach>
I don't think so. I don't know whether it is formally stated, but the loop clauses are mostly executed in order.
_cymew_ has joined #commonlisp
<beach>
But there are several gaps in the LOOP specification. It is not clear, for instance, whether a for-as-arithmetic variable can take on a value outside the ones implied by the iteration.
<beach>
MIT LOOP does assign such values, but Khazern does not.
<beach>
,(loop for i from 1 to 4 finally (return i))
<ixelp>
(loop for i from 1 to 4 finally (return i)) => 5
<beach>
That would return 4 in Khazern.
* semz
seems to recall some fun related to this and type declarations from a while ago
<beach>
Yes: ,(loop for i of-type (unsigned-byte 2) from 0 below 4 finally (return i))
<ixelp>
(loop for i of-type (unsigned-byte 2) from 0 below 4 finally (return i)) ; Warning: The form 4 evaluated to 4, which was not of the anticipated type #1=(UNSIGNED-BYTE 2). ↩ ; Current LOOP context: FOR I OF-TYPE #1# FROM 0 BELOW 4 FINALLY. ↩ ; While executing: ANSI-LOOP::LOOP-WARN, in process Initial(0). ↩ => 4
<beach>
That works in Khazern.
<beach>
When I rewrite the standard, I'll fix that problem. :)
<semz>
hehe
<beach>
Unlike other WSCL issues, that one might be controversial, though, since pretty much all implementations use MIT or something similar.
<beach>
... and I suspect people would rather their implementation be wrong that taking the time to fix it.
bilegeek has quit [Quit: Leaving]
<beach>
Of course, they wouldn't have to fix it if they use Khazern instead.
rogersm has joined #commonlisp
rgherdt has quit [Ping timeout: 272 seconds]
rgherdt has joined #commonlisp
rogersm has quit [Remote host closed the connection]
bjorkintosh has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
bjorkintosh has joined #commonlisp
bjorkintosh has joined #commonlisp
Inline has quit [Ping timeout: 246 seconds]
msv has joined #commonlisp
josrr has quit [Ping timeout: 246 seconds]
a51 has quit [Ping timeout: 255 seconds]
Inline has joined #commonlisp
a51 has joined #commonlisp
Inline has quit [Excess Flood]
zetef has quit [Remote host closed the connection]
Inline has joined #commonlisp
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
a51 has quit [Quit: WeeChat 4.2.1]
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
yitzi has quit [Remote host closed the connection]
danse-nr3 has quit [Ping timeout: 276 seconds]
cstml has joined #commonlisp
rogersm has joined #commonlisp
ymir has quit [Ping timeout: 260 seconds]
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
danse-nr3 has joined #commonlisp
traidare has quit [Ping timeout: 272 seconds]
josrr has joined #commonlisp
danse-nr3 has quit [Remote host closed the connection]
danse-nr3 has joined #commonlisp
cstml has quit [Ping timeout: 246 seconds]
<gilberth>
scymtym: Well, the task is to tell whether FOO is known as a declaration. You mentioned SB-CLTL2:DECLARTION-INFORMATION. But it is buggy and doesn't report e.g. SB-EXT:MUFFLE-CONDITIONS as a known declaration. Which I kind of expected actually because I found that CLtL2 API being buggy in general. It's buggy for CCL as, but CCL:DECLARATION-INFORMATION works just fine. CCL reports all declarations including built-in.
<gilberth>
Thus the questions remains, with SBCL how to tell whether FOO is a known declaration or not? So far I haven't found a way.
tyson2 has quit [Read error: Connection reset by peer]
dra has joined #commonlisp
dra has quit [Changing host]
dra has joined #commonlisp
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
dra has quit [Ping timeout: 256 seconds]
traidare has joined #commonlisp
unl0ckd has quit [Ping timeout: 268 seconds]
dra has joined #commonlisp
dra has quit [Changing host]
dra has joined #commonlisp
reb has joined #commonlisp
danse-nr3 has quit [Ping timeout: 276 seconds]
danse-nr3 has joined #commonlisp
<scymtym>
gilberth: is it buggy and doesn't report certain declarations or is it buggy because it doesn't report certain declarations?
sabrac has joined #commonlisp
dra has quit [Ping timeout: 240 seconds]
<gilberth>
It doesn't report e.g. SB-EXT:MUFFLE-CONDITIONS as a declaration, which it is, it's not a type.
<scymtym>
i see. i wasn't sure whether you had discovered other problems in addition to that
<sabrac>
Hello everyone
<beach>
Hello sabrac.
<gilberth>
No, I was just curious whether I can find a way with SBCL to answer the question whether (DECLARE (FOO X)) is a type declaration or not.
<gilberth>
Something a macro writer might need.
<beach>
My guess is that SB-CLTL2:DECLARATION-INFORMATION is reporting only stuff that has been proclaimed as DECLARATION, so that the compiler should ignore it. That is not the case for the implementation-specific declarations, of course, and you are probably supposed to know what they are.
<beach>
It would probably be better to find the SBCL-specific operator for figuring out type definitions.
<beach>
.. and by "you are supposed to", I really meant "one is supposed to".
<scymtym>
maybe the question can be approached from the other side using the second value of SB-INTROSPECT:DEFTYPE-LAMBDA-LIST. but i'm not sure that the union of all classes and all types identified via that function is equal to all types
rocx has quit [Remote host closed the connection]
<gilberth>
beach: Sure. I would need to read the compiler, copy, paste, hard-code a list of declarations and then closely watch any changes in SBCL. Great!
<gilberth>
And as mentioned the other night: There are two questions a Lisp system may need to answer: (1) Is FOO a type? (2) Is FOO a declaration? It might be neither.
<beach>
Indeed.
<gilberth>
From a macro writer perspective I believe erroring on the "FOO is a type" side has a greater chance of success than erroring on the "FOO is a declaration" side. Hence I was focusing on the question about being a declaration here.
<gilberth>
My line of reasoning is: Suppose there is a declaration (that you are not aware of) called AUTHOR. And you want to implement LET* as a macro. You have a greater chance of success, I believe, when you make (LET ((JOE 10) (JANE 20)) (DECLARE (AUTHOR JOE)) ...) into (LET ((JOE 10)) (DECLARE (AUTHOR JOE)) (LET ((JANE 20)) ...) ...) instead of (LET ((JOE 10)) (LET ((JANE 20)) (DECLARE (AUTHOR JOE)) ...) ...)
wacki has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
notzmv has quit [Ping timeout: 268 seconds]
tok has joined #commonlisp
epony has joined #commonlisp
unl0ckd has joined #commonlisp
danse-nr3 has quit [Ping timeout: 264 seconds]
szkl has joined #commonlisp
rogersm has quit [Quit: Leaving...]
occ has joined #commonlisp
<bike>
probably also a greater chance given how rare it is to proclaim DECLARATIONs at all.
<gilberth>
bike: I doubt that implementation-defined declaration are rare. I mean, the authors of the Lisp implementation put them there for some reason, don't they?
<gilberth>
No issue for a user-defined LET* though as it sees user code, but might be an issue, when I attempt to code walk a bit.
<bike>
not as rare as someone putting in their own declaration, but still less common than type declarations
<bike>
i'm not saying there shouldn't be some way to tell, of course
<bike>
tangent: it just occurred to me that the underdevelopment of declarations is inconvenient. imagine if multiple implementations had something like sb-ext:muffle-conditions (e.g. if i implemented it for cleavir). there'd be no way to even have a portability library defining an alias. code would have to do #+sbcl #+clasp everywhere.
<bike>
i mean, inconvenient in this specific way. i already knew it was inconvenient
<beach>
Heh.
<gilberth>
My reason for erroring on the type side: SBCL, while compiling, doesn't know whether FOO is a class or not. It is notoriously bad at separating compile-time from run-time environments and FIND-CLASS still isn't working.
ym has joined #commonlisp
<gilberth>
So I would expect this spilling over to whatever means I would find to ask the question "Is FOO a type?". But I haven't bothered looking.
X-Scale has joined #commonlisp
<Bubblegumdrop>
(let ((path #P"/tmp/some/file.type")) (make-pathname :name (pathname-name path) :type (pathname-type path))) ;; Does this code exist in cl already? There's pathname-name and pathname-type, I feel like "extract the full filename.type" is a common enough operation?
<bike>
i think in sbcl you might have to dip into sb-int:info to check if something's a type. which would be bad.
<ixelp>
CLHS: Function NAMESTRING, FILE-NAMESTRING...
<Shinmera>
the oft forgot file-namestring
<bike>
but that doesn't give you a pathname, right?
<gilberth>
Still, after this issue has been known for ages, they could have fixed FIND-CLASS.
<Shinmera>
sure
<Shinmera>
if it has to be a pathname then yes the pathname-utils function you linked is adequate
<gilberth>
bike: Neverthless, I'm fine with implementation-specific means. For my declaration or type questions I would need some anyway, as ANSI-CL provides no way.
<bike>
yeah, i mean it would be nice if there was at least an implementation export. i used sb-int in a portability library once and it's just been headaches
<gilberth>
Yes, especially when you want to do that with an implementation, that you otherwise don't use. Before you noticed, your tapping into internals breaks.
<Bubblegumdrop>
Thanks!
<bike>
for an actual deftype type, you could use sb-ext:typexpand. but that wouldn't cover implementation types. like the alien types probably.
<ixelp>
(join-strings (list "the" "fat" "cat" "shat" "on" "the" "mat") " ") ERROR: Undefined function JOIN-STRINGS called with arguments (("the" "fat" "cat" "shat" "on" "the" "mat") " ") .
<shka>
source code seems to say "yes" but i thought it would be good to check it here
wacki has quit [Ping timeout: 256 seconds]
wacki has joined #commonlisp
<younder>
I think the reason lispers put up with the CL library's lousy string functions is because the all-powerful format let's you work around it.
<gilberth>
younder: You just coded a major security hole.
<gilberth>
I mean, what happens when separator includes a tilde?
<gilberth>
But then the urge to paste strings already pushes you to that unsafe realm.
<younder>
You get a format error?
<gilberth>
younder: ~/EVIL-FUN/
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
pranavats has joined #commonlisp
<younder>
Perhaps.. Seems a bit contrived
<gilberth>
How so?
<gilberth>
Would I as a user of your function expect that the separator parameter is spliced into a format string?
attila_lendvai_ has quit [Ping timeout: 255 seconds]
<gilberth>
Try (join-string "~-1*" '("a" "b")) e.g.
<younder>
What I really want is a curry so I could write (apply (curry concatenate 'string) (zip list (duplicate "\\" (length list))))
<gilberth>
Like (defun curry (fun &rest args) #'(lambda (&rest more) (apply fun (append args more))))?
<gilberth>
That's one-liner.
bubblegum has quit [Ping timeout: 264 seconds]
<younder>
That is cool!
bubblegum has joined #commonlisp
mariari has quit [Ping timeout: 256 seconds]
_cymew_ has quit [Ping timeout: 260 seconds]
<gilberth>
And btw, what's wrong with (defun join (s l) (with-output-to-string (o) (do ((q l (cdr q))) ((endp q)) (princ (car q) o) (when (cdr q) (princ s o)))))
<gilberth>
However, I would prefer a more general JOIN function which works on all types of sequences, not just strings.
mariari has joined #commonlisp
ronald_ has joined #commonlisp
ronald has quit [Read error: Connection reset by peer]
<gilberth>
Another option is REDUCE: (defun join (sep list) (reduce #'(lambda (&optional (x nil xp) y) (if xp (concatenate 'string x sep y) "")) list))
<gilberth>
But that with-string-output-stream version perhaps is the fastest.
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
johnjaye has quit [Ping timeout: 272 seconds]
epony has joined #commonlisp
johnjaye has joined #commonlisp
chomwitt has quit [Ping timeout: 246 seconds]
bubblegum has quit [Ping timeout: 276 seconds]
bubblegum has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
dra has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
bubblegum has quit [Ping timeout: 260 seconds]
bubblegum has joined #commonlisp
BrokenCog has quit [Remote host closed the connection]
traidare has quit [Ping timeout: 264 seconds]
rgherdt_ has quit [Remote host closed the connection]
BrokenCog has joined #commonlisp
rgherdt has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
dra has quit [Ping timeout: 240 seconds]
shka has quit [Ping timeout: 256 seconds]
wacki has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
synchromesh has joined #commonlisp
synchromesh has quit [Client Quit]
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
rgherdt has quit [Remote host closed the connection]
sabrac has quit [Ping timeout: 276 seconds]
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
ec has quit [Remote host closed the connection]
ec has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #commonlisp
bubblegum has quit [Ping timeout: 264 seconds]
morganw has quit [Ping timeout: 256 seconds]
samebchase2 has joined #commonlisp
bubblegum has joined #commonlisp
artyn has quit [Ping timeout: 256 seconds]
nathanb has quit [Ping timeout: 264 seconds]
theothornhill has quit [Ping timeout: 264 seconds]
payphone has quit [Ping timeout: 264 seconds]
jonlevin has quit [Ping timeout: 264 seconds]
chiheisen has quit [Ping timeout: 264 seconds]
sirufer has quit [Ping timeout: 264 seconds]
zyd has quit [Ping timeout: 264 seconds]
migalmoreno has quit [Ping timeout: 264 seconds]
paulapatience has quit [Ping timeout: 264 seconds]
alethkit has quit [Ping timeout: 256 seconds]
whereiseveryone has quit [Ping timeout: 256 seconds]
sherbert has quit [Ping timeout: 256 seconds]
cpli has quit [Ping timeout: 256 seconds]
ggb has quit [Ping timeout: 256 seconds]
mhcat has quit [Ping timeout: 256 seconds]
Schnouki has quit [Ping timeout: 256 seconds]
SunClonus has joined #commonlisp
rselim has quit [Ping timeout: 264 seconds]
brettgilio has quit [Ping timeout: 264 seconds]
jmbr has quit [Ping timeout: 264 seconds]
pvac has quit [Ping timeout: 264 seconds]
samebchase has quit [Ping timeout: 255 seconds]
samebchase2 is now known as samebchase
amb007 has quit [Ping timeout: 268 seconds]
artyn has joined #commonlisp
zyd has joined #commonlisp
sirufer has joined #commonlisp
payphone has joined #commonlisp
chiheisen has joined #commonlisp
mesaoptimizer has quit [Ping timeout: 264 seconds]
Schnouki has joined #commonlisp
morganw has joined #commonlisp
nathanb has joined #commonlisp
paulapatience has joined #commonlisp
theothornhill has joined #commonlisp
migalmoreno has joined #commonlisp
jmbr has joined #commonlisp
ggb has joined #commonlisp
whereiseveryone has joined #commonlisp
mhcat has joined #commonlisp
pvac has joined #commonlisp
alethkit has joined #commonlisp
cpli has joined #commonlisp
brettgilio has joined #commonlisp
rselim has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
synchromesh has joined #commonlisp
bubblegum has joined #commonlisp
johnjaye has quit [Ping timeout: 276 seconds]
sherbert has joined #commonlisp
jonlevin has joined #commonlisp
bubblegum has quit [Ping timeout: 255 seconds]
bubblegum has joined #commonlisp
bubblegum has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
bubblegum has joined #commonlisp
mesaoptimizer has joined #commonlisp
mm007emko has quit [Read error: Connection reset by peer]