Comments (6)
Working on pipes right now.
from expr.
π 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.
Currently no, but I think it can be added. Why do you need it?
from expr.
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.
@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.
@PaluMacil I totally agree pipes add readability. Will definitely implement pipes, but don't know the exact timing yet.
from expr.
Related Issues (20)
- Constant 1 overflows int64 when compiling expressions with int64 type parameters HOT 2
- Feature request: UNKNOWN type HOT 6
- trying to understand expr lang more, is there anything that expression can do that goja / otto cant and vice versa? HOT 2
- Feature requestοΌtwo builtin array functions HOT 2
- it is really fast. question on language compatibility issue... HOT 2
- Add `flatten()` builtin HOT 3
- how to implement the 'like' bool expression using expr HOT 1
- Add better documentation about `min` `max` builtins
- invalid char escape HOT 1
- *vm.Program Not Safe HOT 1
- Support matches for bytes HOT 1
- Question: Is there planned support for iterator in version 1.23? HOT 6
- pass nil to interface method get runtime error "Call using interface {} as type *int (1:5)"
- expr.AsKind not work? HOT 4
- Language support for VSCode? HOT 5
- Double definition of Variable/Function not usable anymore. HOT 2
- Cannot use map[string]interface {} as argument (type main.Env) to call dump HOT 5
- Functions defined on the struct are bidden to the Env they were compiled with HOT 6
- Create custom function with many arguments HOT 1
- Feature request: allow multiple expressions in a single program HOT 4
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 expr.