Skip to content

Commit

Permalink
README: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Dec 6, 2023
1 parent 4466644 commit e9add15
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ An important design goal is that a somewhat experienced developer -- especially
In the following code snippet, you'll might recognize familiar mechanisms like function calls and pattern recognition. There's also some standard FP idioms like partial application and composition (and a monad!). You might also spot a fun trick (operators-as-functions)!

```java
defn arithmetic(op) ^(
?(op){
["add"]: (+);
["subtract"]: (-);
["multiply"]: (*);
["divide"]: (/);
: Left@ "Invalid"
}
);
def adder: arithmetic("add");
def subtractor: arithmetic("subtract");
def tripler: (*)|3|;
Expand All @@ -40,19 +49,7 @@ sub5(12); // 7
3 #> tripler #> adder(3, #) #> sub5; // 7

compute(3); // 7
(<+)(sub5, add3, tripler)(3); // 7

// ***********************

defn arithmetic(op) ^(
?(op){
["add"]: (+);
["subtract"]: (-);
["multiply"]: (*);
["divide"]: (/);
: Left@ "Invalid"
}
)
(<+)(sub5, add3, tripler)(3) // 7
```

----
Expand Down

0 comments on commit e9add15

Please sign in to comment.