Hacker News new | ask | show | jobs
by almostjazz 52 days ago
Side comment: |> and %>% aren't the same btw! The newish base pipe (|>) is faster but doesn't support using the dot (.) placeholder to pipe into something other than the first argument of a function, which can sometimes make things a little cleaner.
1 comments

The base pipe has an underscore as a placeholder. From the docs:

Usage:

     lhs |> rhs
Arguments:

     lhs: expression producing a value.

     rhs: a call expression. 
Details: [...]

     It is also possible to use a named argument with the placeholder
     ‘_’ in the ‘rhs’ call to specify where the ‘lhs’ is to be
     inserted.  The placeholder can only appear once on the ‘rhs’.
I believe this wasn't added in the initial implementation of the base pipe so some didn't realize it got included later, and still does not let you use constructs like e.g. combining multiple transformations of the input on the rhs. But for most purposes it's certainly sufficient
I fail to see your point, as the base pipes can be combined with blocks and wrapping the target function into another function.

Although, IMHO, if that many operations are crammed into a single pipe pass, then something is amiss.