pytoolz / pytoolz/toolz

consider add "for_each" function

Open
#445 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

Hello, will toolz consider add "for_each" function?
In scala,
Scala> Array(“hbase”,”hive”,”spark”,”hadoop “).foreach(a => print(a + ’ ‘))

"for_each" function can perform a process on each element immediately.
Consider this case:

@curry
def for_each(proc, eles):
for ele in eles:
proc(ele)

.......

with open(out_path, "w", encoding='utf8') as fout, open(src_path, 'r', encoding='utf8') as fin:
    pipe(fin,
        map(lambda e: e.strip().split('\t')),
        filter(lambda e: len(e) == 3),
        for_each(lambda e: fout.write(e[1]+'\n'))
    )

Will toolz consider it? or do we have better method?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed for_each(proc, eles) behavior and the pipe usage shown in the issue. Review toolz's existing collection and pipeline APIs, then determine whether this function belongs in the library or whether an existing method is preferred; done means a decided API direction with appropriate implementation and tests if accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.