Skip to content

Commit

Permalink
Merge pull request #111 from llewelld/iss110-intro
Browse files Browse the repository at this point in the history
Update Getting Started text
  • Loading branch information
ReubenJ authored Nov 14, 2024
2 parents eb48edf + a39216a commit 5fb8256
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/src/get_started.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started

You can either paste this code into the Julia REPL or into a seperate file, e.g. `get_started.jl` followed by `julia get_started.jl`.
You can either paste this code into the Julia REPL or into a seperate file, e.g. `get_started.jl`. If using a separate file you can execute using `julia get_started.jl` or `julia --project=. get_started.jl` depending on whether you installed Herb.jl globally or in a project.

To begin, we need to import all needed packages using

Expand Down Expand Up @@ -33,7 +33,7 @@ problem = Problem([IOExample(Dict(:x => x), 2x+1) for x ∈ 1:5])
The problem is given now, let us search for a solution with `HerbSearch`. For now we will just use the default parameters searching for a satisfying program over the grammar, given the problem and a starting symbol using

```julia
iterator = BFSIterator(g, :Number, max_depth=5)
iterator = BFSIterator(g, :Number, max_depth=5)
solution, flag = synth(problem, iterator)
println(solution)
```
Expand All @@ -44,11 +44,14 @@ Eventually, we want to test our solution on some other inputs using `HerbInterpr

```julia
program = rulenode2expr(solution, g) # should yield 2*6+1
println(program)

output = execute_on_input(SymbolTable(g), program, Dict(:x => 6))
println(output)
```

If you run the completed code it will output both the generated Julia expression and the result from assigning value.

Just like that we tackled (almost) all modules of Herb.jl.

## Where to go from here?
Expand All @@ -70,10 +73,11 @@ g = @csgrammar begin
end

problem = Problem([IOExample(Dict(:x => x), 2x+1) for x 1:5])
iterator = BFSIterator(g, :Number, max_depth=5)
iterator = BFSIterator(g, :Number, max_depth=5)

solution, flag = synth(problem, iterator)
program = rulenode2expr(solution, g) # should yield 2*6 +1
println(program)

output = execute_on_input(SymbolTable(g), program, Dict(:x => 6))
println(output)
Expand Down

0 comments on commit 5fb8256

Please sign in to comment.