Coder Social home page Coder Social logo

`iterrr` macro removed. about iterrr HOT 8 CLOSED

hamidb80 avatar hamidb80 commented on May 31, 2024
`iterrr` macro removed.

from iterrr.

Comments (8)

dbrignoli avatar dbrignoli commented on May 31, 2024 1

It works like a charm, thank you.

the negative side of op: fn(it) is that you cannot name arguments like map((x, y) => x+y)

Yes, I found that out when I first started using iterrr but being able to pick one style or the other depending on what fits the situation is still great despite having to give up renaming args.

from iterrr.

hamidb80 avatar hamidb80 commented on May 31, 2024

hey, I thought it was not very useful to write iterrr everywhere, so I removed it.

back then this style was possible:

(3..6).iterrr:
  filter(it > 3)
  map(n => n - 2)
  each(n):
    acc.add n

do think it worth to bring it back?

Another style that I can think of is:

|>(3..6):
  filter(it > 3)
  map(n => n - 2)
  sum()

from iterrr.

hamidb80 avatar hamidb80 commented on May 31, 2024

here you go:
https://github.com/hamidb80/iterrr/#iterrr-macro

from iterrr.

dbrignoli avatar dbrignoli commented on May 31, 2024

Hi!

My reasons for preferring iterrr to |> are:

  1. I try to avoid operators that are not well known. Seeing .iterrr makes it (much?) easier for people not familiar with the iterrr library to know that it must be something imported from the iterrr module. If I saw |> and didn't know about iterrr it would slow down my parsing of the code I am reading.
  2. I liked I could to break up the a "transform pipeline" into indented lines like op: details. I found it compact and more readable compared to the parenthesised version .op(details)

from iterrr.

dbrignoli avatar dbrignoli commented on May 31, 2024

here you go: https://github.com/hamidb80/iterrr/#iterrr-macro

Thank you! I will check it out ASAP 😄

from iterrr.

hamidb80 avatar hamidb80 commented on May 31, 2024

2. I liked I could to break up the a "transform pipeline" into indented lines like op: details. I found it compact and more readable compared to the parenthesised version .op(details)

the negative side of op: fn(it) is that you cannot name arguments like map((x, y) => x+y)

from iterrr.

hamidb80 avatar hamidb80 commented on May 31, 2024

It works like a charm, thank you.

the negative side of op: fn(it) is that you cannot name arguments like map((x, y) => x+y)

Yes, I found that out when I first started using iterrr but being able to pick one style or the other depending on what fits the situation is still great despite having to give up renaming args.

hey, just checked out that you can ignore pars in iterrr macro version, likeL

import iterrr

let points = @[(1, 2), (-3, 4), (12, 3), (-1, -6), (5, -9)]
points.items.iterrr:
  map (x, y) => x
  filter it > 0
  each n:
    echo n

that's pretty neat in my opinion.

from iterrr.

dxxb avatar dxxb commented on May 31, 2024

that's pretty neat in my opinion.

Indeed! Thank you for documenting this. FYI I have added support for nestable .iterrr: calls on a my fork's dev branch and I am looking to see if it's possible to add support for naming args like this map: (x, y) => x+y. See https://github.com/dxxb/iterrr/commits/dev and dxxb@0a6d444

from iterrr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.