Comments (7)
IIRC the piped arg goes first in Elixir
https://elixirschool.com/en/lessons/basics/pipe_operator
from prql.
Yes, I think that's ideal, thanks @RCHowell
I would tend to have the settings of the function be first, and the column arg last, because pipes put their input last, so the most flexible arguments should go last, e.g. salary | pct 0.5
. And if we allowed partial functions, this would be compatible; i.e. func median = pct 0.5
).
If you want to have a go at a few example functions, they could go into examples
!
from prql.
What about a placeholder, because some aggregations can take multiple identifier expressions such as corr col_1, col_2
?
Also, "settings" of the function typically goes after the "core" arguments in the case of function overloading. A simple example would be foo.indexOf(bar)
and foo.indexOf(bar, offset)
ie default parameters via overloading.
from prql.
Ah, so in R, the piped argument goes first:
x %>% f(y)
is equivalent tof(x, y)
Are there other languages which work that way? Here's an example of OCaml approach, where they go last: https://github.com/max-sixty/prql/issues/11#issuecomment-1021911352
For optional args, then the order doesn't matter, so that would be bar | indexOf offset:1
with either of the options...
from prql.
Nice find @RCHowell .
So we have pipes putting the arg
- Last: OCaml + F#
- First: R + Elixir
Julia has implementation that do each (e.g. Chain.jl vs DataPipes.jl)!
An advantage of putting it last is that partials work (func median = pct 0.5
), and it makes more sense to me that the settings of a function bind more tightly than what the function runs on.
But I don't have a super-confident view, so whatever the consensus is I'm happy with.
from prql.
Here's a discussion of Clojure's approach, which has a pipe symbol for each type (!): https://clojure.org/guides/threading_macros
from prql.
Closing — we went ahead with the Ocaml & F# approach. Not completely immutable; we can see how we go.
from prql.
Related Issues (20)
- Modules containing data (tables, relations) HOT 3
- Release plan for 0.11.1 HOT 2
- Nightly tests failed HOT 1
- Remove `std.prql_version` in favor of `std.prql.version` HOT 5
- Nightly tests failed HOT 4
- Grouping breaks `select * except` HOT 2
- Set up text "fixture" for CLI project tests
- Clickhouse DATETIME conversion invalid format HOT 4
- Zig tests started failing HOT 3
- The various exit status codes from `prqlc` HOT 2
- Python compiler needs a flag to return the full sequence of errors as json HOT 5
- Compiler panic with `sort` in inline join relation HOT 5
- Nightly tests failed HOT 1
- `**` operator (or something else) for `math.pow` HOT 1
- Nightly tests failed HOT 1
- Nightly tests failed HOT 1
- First-class functions
- Nightly tests failed
- Nightly tests failed HOT 1
- Add comments to `fmt` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prql.