hamidb80 / iterrr Goto Github PK
View Code? Open in Web Editor NEWiterate faster ... ๐๏ธ. functional-style, extensible iterator library
License: MIT License
iterate faster ... ๐๏ธ. functional-style, extensible iterator library
License: MIT License
let's say we have an string i
, and we wanna iterator over it line by line
import std/strutils
let i = "..."
but this style of writing uses the funcion of splitLines
i.splitLines.iterrr:
map it.strip()
toseq()
but this style of writing uses the iterator of splitLines
iterrr i.splitLines:
map it.strip()
toseq()
what I have in mind:
1..20 >< imap[number](number + 1)
or tuple unpacking
"hello".pairs >< imap[indx, ch](indx + 1)
(1.. 10) |>
alter(echo it)
.toseq()
(1 .. 10) |> define(
a = it + 1
b = a +2
)
.map(b)
.toseq()
choose random name for acc
variable
like:
flatten
repeat
cycle
zip
.ireduce[acc, a](initialState, [finalizer]):
max(acc, a)
iterrr
was removed by 1ceb979. Is it possible to have it back or implement it in my own code using symbols exported from the iterrr
module? I used to be able to write stuff like this:
dest = something.iterator.iterrr:
map: do_something(it) # do_something
map: do_something_else(it) # do_something_else
toSeq()
and loved it ๐ . Thank you!
!>
- ( use -d:iterrrDebug
instead)I have the following code:
echo:
@[@[1,2],@[3,4]].pairs |>
map[ia,a](
a.pairs |>
map[ib,_]($(ia==ib)).
strJoin()).
strJoin()
result: truetruetruetrue
and the indicies schoudnt be all the same
Something like iter
or toIter
or iterrr
it looks better when debugging
template iterrrFn7(s: untyped; _: untyped): untyped {.dirty.} =
s
to :
template iterrrFn7(s, _): untyped {.dirty.} =
s
points |> imap((x,y) => x+y)
like:
(1..10) >< map[n]:
n + 1
Some thing like for*
in Racket-lang.
Use filter
instead of #:when
My view is that a lot of the time in Nim when you're doing filter or map you're just going to operate it on afterwards
for data in lines("file").map(parseInt):
echo data
-beef-
my solution
lines("file") >< imap(parseInt).do(data):
echo data
The default finalizer is i_toSeq
if it's not set explicitly.
Other finalizers can be:
shadowing variable names doenst seem to work correctly.
neither with custom name:
echo:
@[@[1,2],@[3,4]].items |>
map[a](
a.items |> map[a](a+1).toSeq()).
toSeq()
nor with it:
echo:
@[@[1,2],@[3,4]].items |>
map(
it.items |> map(it+1).toSeq()).
toSeq()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.