Repository navigation
Stdlib completion effort
Patrick Hammer edited this page Oct 28, 2025
·
84 revisions
Copied from https://github.com/tezena/PeTTa-and-MeTTa-comparisons/blob/main/README.md, thank you @tezena and @hal-29
There will be fast iteration in the coming days to complete and correct Stdlib.
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 1 | !(bind! A B) |
✅ | For space and states but not general atom binding | |
| 2 | !(union-atom (1 2) (3 4)) |
✅ | ✅ | Works on both |
| 3 | !(cons-atom 0 (1 2 3)) |
✅ | ✅ | Works on both |
| 4 | !(intersection-atom (1 2) (3 4)) |
✅ | ✅ | Works on both |
| 5 | !(car-atom (1 2 3)) |
✅ | ✅ | Works on both |
| 6 | !(cdr-atom (1 2 3)) |
✅ | ✅ | Works on both |
| 7 | !(superpose (1 2 3)) |
✅ | ✅ | Works on both |
| 8 | !(collapse (superpose(1 2 3))) |
✅ | ✅ | Works on both |
| 9 | !(index-atom (1 2 3) 1) |
✅ | ✅ | Works on both |
| 10 | !(size-atom (1 2 3)) |
✅ | ✅ | Works on both |
| 11 | !(sort-atom (3 1 4 2 3)) |
❌ | ✅ | Works only on PeTTa |
Below are additional built-ins tested from the MeTTa stdlib pages. Each row shows whether it worked under MeTTa and PeTTa in this workspace, plus a brief note. Tests live alongside this document as .metta files named tests_*.metta.
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 10 | (= (add 1 2) 3) |
✅ | ✅ | Works on both |
| 11 | !(id 5) |
✅ | ✅ | Works on both |
| 12 | !(=alpha (Father $X) (Father $Y)) |
✅ | ✅ | Works on both |
| 13 | !(=alpha (Father $X) (Son $X)) |
✅ | ✅ | Works on both |
| 14 | !(if-equal 1 1 "Equal" "Not Equal") |
✅ | ✅ | Works via !(import! &self lib_he)
|
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 15 | !(assertEqual (+ 1 2) (- 6 3)) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 16 | !(assertAlphaEqual (h $x $y) (h $a $b)) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 16 | !(assertAlphaEqual (+ $x $y) (+ $a $b)) |
✅ | Needs !(import! &self lib_he) but with quote since + does not typecheck for performance reasons. |
|
| 17 | !(assertEqualToResult (+ 1 2) 3) |
✅ | ❌ | MeTTa implementation anyone? |
| 18 |
!(assertAlphaEqualToResult (adder) ($y)) with (= (adder) $x)
|
✅ | ❌ | MeTTa implementation anyone? |
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 19 | !(Error (add "a" 2) BadType) |
✅ | ✅ | Works in both, but for an expression to return an error instead of returning (empty) it must use catch, e.g. (catch (+ a 2)). |
| 20 | !(if-error (Error 5 BadType) "Error!" "No error") |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 21 | !(return-on-error (Error 5 BadType) 6) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 22 | !(function (return 5)) |
✅ | ❌ | Not planned. |
| 23 |
!(eval (double 5)) with (= (double $x) (+ $x $x))
|
✅ | ✅ | Works in both |
| 24 | !(evalc (+ 5 5) &self) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 25 | !(chain (+ 2 3) $x (* $x 2)) |
✅ | ✅ | Works in both |
| 26 | !(for-each-in-atom (1 3 5 62 2 5) println!) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 27 | !(pow-math 2 3) |
✅ | ✅ | Works on both |
| 28 | !(sqrt-math 9) |
✅ | ✅ | Works on both |
| 29 | !(abs-math -5) |
✅ | ✅ | Works on both |
| 30 | !(log-math 10 100) |
✅ | ✅ | Works on both |
| 31 | !(trunc-math 5.6) |
✅ | ✅ | Works on both |
| 32 | !(ceil-math 5.2) |
✅ | ✅ | Works on both |
| 33 | !(floor-math 5.8) |
✅ | ✅ | Works on both |
| 34 | !(round-math 5.4) |
✅ | ✅ | Works on both |
| 35 | !(round-math 5.6) |
✅ | ✅ | Works on both |
| 36 | !(sin-math 0) |
✅ | ✅ | Works on both |
| 37 | !(asin-math 0) |
✅ | ✅ | Works on both |
| 38 | !(cos-math 0) |
✅ | ✅ | Works on both |
| 39 | !(acos-math 1) |
✅ | ✅ | Works on both |
| 40 | !(tan-math 0) |
✅ | ✅ | Works on both |
| 41 | !(atan-math 0) |
✅ | ✅ | Works on both |
| 42 | !(isnan-math 0.0) |
✅ | ✅ | Works on both |
| 43 | !(isinf-math 0.0) |
✅ | ✅ | Works on both |
| 44 | !(min-atom (2 6 7 4 9 3)) |
✅ | ✅ | Works on both |
| 45 | !(max-atom (2 6 7 4 9 3)) |
✅ | ✅ | Works on both |
| No | Test Case | MeTTa | PeTTa | Observations |
|---|---|---|---|---|
| 46 | !(superpose (A B C)) |
✅ | ✅ | Works on both |
| 47 | !(collapse (superpose (A B C))) |
✅ | ✅ | Works on both |
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 48 | !(is-function (-> Atom Atom)) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 49 | !(is-function Atom) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 50 |
!(type-cast A type1 &self) with (: type1 Type)
|
✅ | ❌ | Not planned. |
| 51 | !(type-cast 1 type1 &self) |
✅ | ❌ | Not planned. |
| 52 | !(match-types Atom Atom "Matched!" "Didn't match") |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 53 | !(match-types Atom Number "Matched!" "Didn't match") |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 54 | !(first-from-pair (A B)) |
✅ | ✅ | Works on both |
| 55 | !(second-from-pair (A B)) |
❌ | ✅ | Works only in PeTTa |
| 55 | !(match-type-or True Number Bool) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 56 | !(foldl-atom (1 2 3 4) 0 $acc $x (+ $acc $x)) |
✅ | ✅ | Works on both |
| 57 | !(map-atom (1 2 3) $x (+ $x 1)) |
✅ | ✅ | Works on both |
| 58 | !(filter-atom (1 2 3 4 5) $x (> $x 3)) |
✅ | ✅ | Works on both |
| 59 | !(foldl-atom (1 2 3 4) 0 foldfunc) |
❌ | ✅ | Works only on PeTTa |
| 60 | !(map-atom (1 2 3) mapfunc) |
❌ | ✅ | Works only on PeTTa |
| 61 | !(filter-atom (1 2 3 4 5) filterfunc) |
❌ | ✅ | Works only on PeTTa |
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 59 | !(add-reduct &self (= (add) (+ 1 3))) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 60 | !(add-atom &self (= (add) (+ 1 3))) |
✅ | ✅ | Works on both |
| 61 | !(get-type 1) |
✅ | ✅ | Works in both |
| 62 |
(: a A) then !(get-type-space &self a)
|
✅ | ✅ | Works via !(import! &self lib_he)
|
| 63 | !(get-metatype True) |
✅ | ✅ | Works on both |
| 64 | !(get-metatype (a b)) |
✅ | ✅ | Works on both |
| 65 | !(new-space) |
✅ | ✅ | Returns new space ref in MeTTa; PeTTa unevaluated yet new spaces can be manipulated nevertheless. |
| 66 | !(bind! state (new-state rest)) |
✅ | ✅ | Works on both |
| 67 |
!(change-state! state active) then !(get-state state)
|
✅ | ✅ | Works on both |
| 68 | !(get-atoms &self) |
✅ | ✅ | Works on both |
| 69 | !(match &self (= (add) (+ $x $y)) $x) |
✅ | ✅ | Works on both |
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 70 | !(quote (+ 1 2)) |
✅ | ✅ | MeTTa returns (quote (+ 1 2)), PeTTa returns (+ 1 2) unreduced. |
| 71 | !(unquote (quote (+ 1 2))) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 73 | !(noreduce-eq (+ 1 2) (+ 1 2)) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| 74 | !(noreduce-eq (+ 1 2) 3) |
✅ | ✅ | Works via !(import! &self lib_he)
|
| No | Test Case | H-E | PeTTa | Observations |
|---|---|---|---|---|
| 75 | !(unique (superpose (a b c d d))) |
✅ | ✅ | Works on both |
| 76 | !(union (superpose (a b b c)) (superpose (b c c d))) |
✅ | ✅ | Works on both |
| 77 | !(intersection (superpose (a b c c)) (superpose (b c c c d))) |
✅ | ✅ | Works on both |
| 78 | !(subtraction (superpose (a b b c)) (superpose (b c c d))) |
✅ | ✅ | Works on both |
| 79 | !(unique-atom (a b c d d)) |
✅ | ✅ | Works on both |
| 80 | !(union-atom (a b b c) (b c c d)) |
✅ | ✅ | Works on both |
| 81 | !(intersection-atom (a b c c) (b c c c d)) |
✅ | ✅ | Works on both |
| 82 | !(subtraction-atom (a b b c) (b c c d)) |
✅ | ✅ | Works on both |