File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,44 @@ func main() {
9898}
9999```
100100
101+ [ Play Online] ( https://play.golang.org/p/4S4brsIvU4i )
102+
103+ ``` go
104+ package main
105+
106+ import (
107+ " fmt"
108+ " github.com/antonmedv/expr"
109+ )
110+
111+ type Tweet struct {
112+ Len int
113+ }
114+
115+ type Env struct {
116+ Tweets []Tweet
117+ }
118+
119+ func main () {
120+ code := ` all(Tweets, {.Len <= 240})`
121+
122+ program , err := expr.Compile (code, expr.Env (Env{}))
123+ if err != nil {
124+ panic (err)
125+ }
126+
127+ env := Env{
128+ Tweets: []Tweet{{42 }, {98 }, {69 }},
129+ }
130+ output , err := expr.Run (program, env)
131+ if err != nil {
132+ panic (err)
133+ }
134+
135+ fmt.Println (output)
136+ }
137+ ```
138+
101139## Contributing
102140
103141** Expr** consist of a few packages for parsing source code to AST, type checking AST, compiling to bytecode and VM for running bytecode program.
You can’t perform that action at this time.
0 commit comments