Skip to content

Commit

Permalink
docs: examples section on README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
BRonen committed Mar 31, 2024
1 parent 3a99e0c commit 0edbeb8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,37 @@ Run the project's tests:
```
clojure -T:build test
```

## Examples

There are literals (variables), strings and integers and every list will be executed as a function call by default.

```clj
(print "string" 123)
```

You can declare variables using the "def" clause, here we define "foo" as the string "bar".

```clj
(def foo "bar")
```

We can run multiple statements using the "do" clause.

```clj
(do (def foo "bar") (print foo))
```

The "fn" clause can declare callables, the second element of the fn will not be executed as code. These literals will be considered just binders to the values that will be received by the call.

```clj
((fn (a b) (+ a b)) 1 2)
```

This callable can be stored on a variable declaration to be called later.

```clj
(do (def example (fn (a b) (+ a b))) (print (example 1 2)))
```

There are a bunch of examples of valid code on the [tests](./test/bronen/kekwisp_test.clj).

0 comments on commit 0edbeb8

Please sign in to comment.