Skip to content

Commit 0271673

Browse files
committed
Update README.md
1 parent 14a9364 commit 0271673

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)