GNU bug report logs -
#76618
30.1.50; need an -unzip-lists function?
Previous Next
Full log
View this message in rfc822 format
tags 76618 + notabug
thanks
Christopher Howard <christopher <at> librehacker.com> writes:
> Hi. The behavior of -zip and -unzip seems strange to me, though this is not exactly my complaint. -zip has the strange behavior that it always returns lists of lists, unless you provide it with two lists, in which case it returns cons cells instead.
>
> Okay, fine, but the documentation for -unzip says
>
> ```
> Unzip LISTS.
>
> This works just like ‘-zip’ but takes a list of lists instead of
> a variable number of arguments, such that
>
> (-unzip (-zip L1 L2 L3 ...))
>
> is identity (given that the lists are the same length).
> ```
>
> But if you try zipping and unzipping two lists, like
>
> (-unzip (-zip '(1 a) '(2 b)))
>
> this throws an error, because -unzip only deals with lists.
>
> One can use -zip-lists, to avoid the error. But then, if your lists happen to be two elements long, you end up with a list of pairs!
>
> ELISP> (-unzip (-zip-lists '(1 a) '(2 b)))
> ((1 . a) (2 . b))
>
> In my case, what I really want to do is unzip and then zip back up. But I get different results (pairs vs. cons) from -unzip depending on the number of lists:
>
> ELISP> (-unzip '((1 a) (2 b) (3 c)))
> ((1 2 3) (a b c))
>
> ELISP> (-unzip '((1 a) (2 b)))
> ((1 . 2) (a . b))
>
> This doesn't quite work:
>
> ELISP> (setq foo (-unzip '((1 a) (2 b))))
> ((1 . 2) (a . b))
>
> ELISP> (-zip (first foo) (second foo))
> <throws error>
>
> Or this:
>
> ELISP> (-unzip '((1 . a) (2 . b)))
> <throws error>
>
> Maybe we just need an -unzip-lists function?
This seems to be about the dash.el library, which is not a part of
Emacs. I'd recommend reporting this to the maintainers of that package
(see `C-h P dash RET`) instead.
This bug report was last modified 67 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.