mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
1.07k stars 50 forks source link

filter does not consider lists as true #108

Closed her01n closed 9 months ago

her01n commented 9 months ago

In scheme list values are accepted as true in boolean context. For example:

λ > (if (list 1 2) 1 2)
=> 1

But, filter only accepts #true as true value:

λ > (filter (lambda (n) (list 1 2)) (list 1 2))
=> '()

The result of the last expression should be:

λ > (filter (lambda (n) (list 1 2)) (list 1 2))
=> '(1 2)

A workaround is to use if explicitly:

λ > (filter (lambda (n) (if (list 1 2) #true #false)) (list 1 2))
=> '(1 2)

I have tested with commit 881262eb1cc34268f82b611312037b8d76875464, on arch linux with rust version "rustc 1.74.0 (79e9716c9 2023-11-13) (Arch Linux rust 1:1.74.0-1)"

mattwparas commented 9 months ago

Thanks for the report - will be fixed in #109

mattwparas commented 9 months ago

Should be fixed now, thanks again for the report! - closed in #109