These are chat archives for evhub/coconut

24th
Dec 2016
yggdr
@yggdr
Dec 24 2016 00:00
Hi. I've looked at how F#, Elixir, and Mochi handle their pipe operator, and while F# and Mochi seem to do the same thing as Coconut (piping inserts into last place in argument list), Elixir has its pipe insert into the first place. I have not used any of these languages besides playing with them a bit, so I have not formed a opinion on this, but I can see uses for both. For functions with arguments that are somewhat "equal" (like "+", "*") Coconuts behaviour is intuitive: you just fill up arguments in order, and piped in ones go last. But Elixir's model has its uses in cases where a function takes only one necessary argument , and one or more options. Easiest example is the print function with its end option. I have to explicitly set these options in named parameters "print$(end='\n')" and can't just enumerate them (here print is a bad example since end is kw only, but you know what I mean). So what would people with more experience in languages with pipe operators think about an alternative pipe in Coconut that inserts in front of explicitly given arguments instead of after them? Useful, or not?
Eric Anderson
@Nexus6
Dec 24 2016 02:58
@yggdr If I understand you, Coconut-develop already has what you're looking for. You can use the ? symbol as a placeholder for where you want the piped parameters to go. Simple example: >>> [1,2,3] |> reduce$((+), ?, 10)
16