julia> x = [3,2,4,5]
4-element Array{Int64,1}:
3
2
4
5
julia> x |> sort |> x->reshape(x,(2,2))
2×2 Array{Int64,2}:
2 4
3 5
works.It gives a syntax error if the pipes are on the newline. Is that your gripe?
Or is it that it doesn't automatically partially apply the function, requiring you to use an anonymous function, like `x->reshape(x,(2,2))` instead of as you have it `resize(100,100)` implicitly. I prefer the explicitness.
You don't know what you're missing by not having an inspect function. In elixir it's styled "IO.inspect", and it pretty-prints the value as a side-effect, and returns the value unchanged. You can pass a "label" option as your second parameter, and that will add a label to the pretty print. For example, assume I have a module M with the expected functions:
value = 10
|> M.add_3 |> IO.inspect(label: "A")
|> M.times(4) |> IO.inspect(label: "B")
|> M.minus_2 |> IO.inspect(label: "C")
will print: A: 13
B: 52
C: 50
and value will be assigned 50.Now, the great thing about that is that you can blat a bunch of IO.inspects simultaneously using multiline cursors. That low friction 1) causes you to actually use it, and 2) cause you to also set your code up so that it's easy to IO.inspect, which typically also means cleaner, and easier to read code. It is IMO the most powerful debugging tool that I've ever used.
Example: https://github.com/ityonemo/ex_dhcp/blob/master/lib/ex_dhcp....
That small pipeline does a pretty complex set of actions - deserialize a raw binary to a structured datatype, then call a handler, then process a handler return result. There are four datatypes that run through that pipeline. Nonetheless, I can inject IO.inspects into that with six keystrokes (I have a vscode snippet), run the code, and watch as the data are transformed, and immediately identify what corner case I missed and write a proper test for it.
And yes, it is far less powerful if the pipes can't tolerate the newline. (though you usually can still multicursor on a single line).
Anyways, I'm not saying this to rag on Julia. I'm just saying I think julia can and SHOULD have this, and it would be awesome. Also, elixir needs to learn a thing or two from julia's repl.
@_ images |> filter(size(_,1)>100, __) .|>
resize(__, 100,100) .|>
crop(__, 25,25,75,75)
with Underscores.jl. Not exactly `images.first.resize(100, 100).crop(25, 25, 75, 75)` anymore, to point out that this doesn't need every function to prioritise one argument, the pipe feeds into __ in any position. And that .|> applies them to each element.It's possible in languages which support extensions, such as Swift, Dart or Kotlin.
But maybe I don't understand your point, if so, tell me what exactly would be impossible to implement in a language like Swift, Dart, Kotlin.