Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msabramo/pyrubyblocks
An experiment with emulating Ruby-style blocks in Python
https://github.com/msabramo/pyrubyblocks
Last synced: about 1 month ago
JSON representation
An experiment with emulating Ruby-style blocks in Python
- Host: GitHub
- URL: https://github.com/msabramo/pyrubyblocks
- Owner: msabramo
- Created: 2011-11-21T15:55:21.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2011-11-21T16:04:56.000Z (about 13 years ago)
- Last Synced: 2024-05-09T20:39:57.281Z (8 months ago)
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
An experiment with emulating Ruby-style blocks in Python.
Some examples:
>>> ListObject([1, 2, 3, 4]).each(ExecBlock("print args[0]"))
1
2
3
4
>>> ListObject([1, 2, 3, 4]).collect(EvalBlock("args[0] ** 2"))
[1, 4, 9, 16]
>>> ListObject([1, 2, 3, 4, 5, 6, 7, 8, 9]).select(EvalBlock("args[0] %2 == 0"))
[2, 4, 6, 8]
>>> ListObject([1, 2, 3, 4, 5, 6, 7, 8, 9]).reject(EvalBlock("args[0] %2 == 0"))
[1, 3, 5, 7, 9]