Skip to content

Commit 8452c67

Browse files
authored
Fix prelude head-or` (#182)
- fix: prelude function `head-or` now works
1 parent 4fbcbbc commit 8452c67

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

harness/test/051_head_or.eu

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"Tests for prelude `head-or`"
2+
3+
head-or-tests: {
4+
α: [] head-or(:none) //= :none
5+
β: [:x, :y, :z] head-or(null) //= :x
6+
ɣ: { colours: [:r, :o, :y, :g, :b, :i, :v] }.{ val: head-or(:x, colours) = head(colours) }.val
7+
δ: [null] head //= [] head-or(null)
8+
}
9+
10+
RESULT: head-or-tests values all-true? then(:PASS, :FAIL)

lib/prelude.eu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ head: __HEAD
6868
nil?: = []
6969

7070
` "`head-or(xs, d)` - return the head item of list `xs` or default `d` if empty."
71-
head-or(d, xs): xs nil? then(xs head, d)
71+
head-or(d, xs): xs nil? then(d, xs head)
7272

7373
` "`tail(xs)` - return list `xs` without the head item. [] causes error."
7474
tail: __TAIL

tests/harness_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,8 @@ pub fn test_harness_049() {
245245
pub fn test_harness_050() {
246246
run_test(&opts("050_edn.edn"));
247247
}
248+
249+
#[test]
250+
pub fn test_harness_051() {
251+
run_test(&opts("051_head_or.eu"));
252+
}

0 commit comments

Comments
 (0)