Git Product home page Git Product logo

Comments (7)

RCHowell avatar RCHowell commented on May 12, 2024 1

IIRC the piped arg goes first in Elixir

https://elixirschool.com/en/lessons/basics/pipe_operator

from prql.

max-sixty avatar max-sixty commented on May 12, 2024

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.

RCHowell avatar RCHowell commented on May 12, 2024

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.

max-sixty avatar max-sixty commented on May 12, 2024

Ah, so in R, the piped argument goes first:

  • x %>% f(y) is equivalent to f(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.

max-sixty avatar max-sixty commented on May 12, 2024

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.

max-sixty avatar max-sixty commented on May 12, 2024

Here's a discussion of Clojure's approach, which has a pipe symbol for each type (!): https://clojure.org/guides/threading_macros

from prql.

max-sixty avatar max-sixty commented on May 12, 2024

Closing — we went ahead with the Ocaml & F# approach. Not completely immutable; we can see how we go.

from prql.

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.