Giter VIP home page Giter VIP logo

Comments (6)

antonmedv avatar antonmedv commented on August 11, 2024 4

Working on pipes right now.

from expr.

antonmedv avatar antonmedv commented on August 11, 2024 2

πŸ‘‰ The other option is making the expr support Unix pipe (|), but I don't know if this idea is good or not.

I have been thinking about this for a lot of time now. It is a good idea. The syntax will be concise and easy to read.

other_tool(s) | tail(1, "=" ) | cut(1, "=")

I like this kind of pipe with the first parameter omitted.

from expr.

antonmedv avatar antonmedv commented on August 11, 2024

Currently no, but I think it can be added. Why do you need it?

from expr.

amikai avatar amikai commented on August 11, 2024

Hi @antonmedv, Thanks for reply.
In my scenario, I need lots of string processing on one string, I implement the custom string processing function, like cut, tail ... and found that the syntax is not elegant when applying the amount of functions on the string: cut(tail(other_tool(s),1, "=" ), 1, "=") .

So I try to implement the Unix like pipe using expr.Function. The pipe function signature will be pipe(s, function(string) func(string) string...), the above example use pipe function will become pipe(s, other_tool(s), cut(1, "="), tail(1, "=")). pipe function POC: https://goplay.tools/snippet/2mRsAyZPvEg

πŸ‘‰ In this implementation, the string processing function can worked in pipe, but not work independently. I want it can be used independently, for example: cut(1, "=")(s), it leads the error unexpected token Bracket("(") now.
πŸ‘‰ The other option is making the expr support Unix pipe (|), but I don't know if this idea is good or not.

from expr.

PaluMacil avatar PaluMacil commented on August 11, 2024

@antonmedv Do you have any thoughts on priority? I understand if you can't work on this and am very thankful for the library, but I figured I could add a use case: I was just reading this and the idea seems pretty exciting. I was doing some research and poking around with frontend html templating using WASM and wanted to use expr in the templates. The pipe feature would really improve readability and usefulness of something like this.

from expr.

antonmedv avatar antonmedv commented on August 11, 2024

@PaluMacil I totally agree pipes add readability. Will definitely implement pipes, but don't know the exact timing yet.

from expr.

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.