Skip to content

Commit

Permalink
Merge pull request #1 from daddinuz/spike
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
daddinuz authored Oct 15, 2024
2 parents ac0b1f9 + 9b02829 commit c009b26
Show file tree
Hide file tree
Showing 36 changed files with 610 additions and 1,632 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
20 changes: 20 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Rust

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
141 changes: 42 additions & 99 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions examples/alice_n_bob.rat

This file was deleted.

2 changes: 2 additions & 0 deletions examples/closure.rat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
: make-adder = [$x add] bind ;
40 2 make-adder i say
2 changes: 1 addition & 1 deletion examples/fact.rat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
: fact [dup zero?] [incr] [dup decr] [mul] linrec ;
: fact = [dup zero?] [incr] [dup decr] [mul] linrec ;
5 fact say
2 changes: 1 addition & 1 deletion examples/fib.rat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
: fib [dup 3 lt] [pop 1] [decr dup decr] [add] binrec ;
: fib = [dup 3 lt?] [pop 1] [decr dup decr] [add] binrec ;
30 fib say
13 changes: 0 additions & 13 deletions examples/parallel-mergesort.rat

This file was deleted.

4 changes: 4 additions & 0 deletions examples/person.rat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
: ^new = [$first-name $last-name $age] bind ;
: ^first-name = 0 at ;
: ^last-name = 1 at ;
: ^age = 2 at ;
6 changes: 3 additions & 3 deletions examples/towards_zero.rat
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
: std @ rat\std ;

: small? 1 lt ;
: small? = 1 lt? ;

# with recursion
: f std\over small? [pop] [[dup decr] dip dup i] if-else ;
: f = std\over small? [pop] [[dup decr] dip dup i] if-else ;
10 [f] f

# with combinators
: f [dup small?] [] [dup decr] [] linrec ;
: f = [dup small?] [] [dup decr] [] linrec ;
10 f

show
10 changes: 5 additions & 5 deletions lib/math.rat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

: std @ rat\std ;

÷ abs dup negative? [neg] if ;
÷ halve 1 shr ;
÷ double 1 shl ;
÷ square dup mul ;
÷ pow [dup quote [mul] cat] dip std\times ;
: ^abs = dup negative? [neg] if ;
: ^halve = 1 shr ;
: ^double = 1 shl ;
: ^square = dup mul ;
: ^pow = [dup quote [mul] cat] dip std\times ;
Loading

0 comments on commit c009b26

Please sign in to comment.