jcoo092
2020-5-14 08:59:51

Is there any sort of zip & unzip functions for lists built into Racket? Or a fairly standard extra package that includes them? I have a particular use for an unzip right now. While I could quite easily write my own function, it’s the sort of thing that I think in practice it is better to use from elsewhere if there’s a ‘standard’ version of it.


spdegabrielle
2020-5-14 09:19:37

jcoo092
2020-5-14 09:21:09

Oh, no, I’m not talking about working with zip files - just something akin to e.g. https://msdn.microsoft.com/visualfsharpdocs/conceptual/list.unzip%5b%27t1%2c%27t2%5d-function-%5bfsharp%5d


soegaard2
2020-5-14 09:40:59

@jcoo092 zip is (map list xs ys)


soegaard2
2020-5-14 09:42:13

It’s in srfi/1 btw.


soegaard2
2020-5-14 09:42:28

So are unzip1, …, unzip5



spdegabrielle
2020-5-14 09:43:47

soegaard2
2020-5-14 09:43:54

I’d prefer (map first ziped-list) over unzip1 though.


samth
2020-5-14 13:09:37

@jcoo092 in general you don’t need zip because map takes multiple list arguments.


jcoo092
2020-5-14 23:34:55

Thanks @spdegabrielle, @soegaard2 & @samth :slightly_smiling_face:


wanpeebaw
2020-5-15 04:42:19

Found a series of video lectures based on HtDP. https://www.youtube.com/channel/UC7dEjIUwSxSNcW4PqNRQW8w