Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map with collection as input, instead of arguments #16

Open
swistak35 opened this issue Sep 4, 2014 · 7 comments
Open

Map with collection as input, instead of arguments #16

swistak35 opened this issue Sep 4, 2014 · 7 comments

Comments

@swistak35
Copy link

What is really missing in shell which is very functional is treating input as an array.
It's different approach than current functions in this library.
For example, I have a file like this:

~% cat testlines 
foo
bar baz
jajco

And if I had some time ago following use case:

~% cat testlines | while read line; do echo $line | base64; done
Zm9vCg==
YmFyIGJhego=
amFqY28K

It would be great to run this like that:

~% cat testlines | mapl 'base64'

Do you think it would fine to include this in your library?

@Tarrasch
Copy link
Owner

Tarrasch commented Sep 5, 2014

That would be totally awesome! This is what I wanted for issue #11 though.

I played around a bit, check this out:

$ cat testlines | each 'echo $x | base64'
Zm9vCg==
YmFyIGJhego=
amFqY28K

Would you be interested in trying to implement this? :)

@swistak35
Copy link
Author

Sure. : )

@Tarrasch
Copy link
Owner

Tarrasch commented Sep 5, 2014

By the way, I think you should name it eachl or eachi (I think i as in input). Since map is the 'never-does'harm' function. But that's not what we want here.

@swistak35
Copy link
Author

Hi, sorry for no response - I sat once and tried to code it, but my shell-fu is definitely not high enough.

@Tarrasch
Copy link
Owner

Yea, shell languages are hell, that's why I rewrote antigen in Haskell :)

@NightMachinery
Copy link

I played around, and this seems to work:

each 'echo $1' "${(f@)$(<~/some-file)}"

@Tarrasch
Copy link
Owner

Yes. But we want a functional left-to-right feeling in this library. I promise I'm still gonna review any good pull requests. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants