Skip to content
ry

Bool

Booleans are R’s TRUE and FALSE, never NA. R’s operators already cover most of this module; its functions exist so that a boolean step can be passed by name, as in List.walk(flags, Bool.true, Bool.and), and so that code written against Roc’s names reads the same.

Function Summary
Bool.true TRUE, as Roc spells it.
Bool.false FALSE.
Bool.and Whether both are TRUE.
Bool.or Whether either is TRUE.
Bool.not The opposite value.
Bool.is_eq Whether two values are equal by identical(), the library’s equality.
Bool.is_not_eq Whether two values differ by identical().
#: logical
Bool.true

TRUE, as Roc spells it. It is a value, not a function.

Bool.true
#> TRUE

Source

#: logical
Bool.false

FALSE.

Bool.false
#> FALSE

Source

Bool.and <- function(first: logical, second: logical) -> logical

Whether both are TRUE. Both arguments are evaluated, unlike with &&.

Bool.and(TRUE, FALSE)
#> FALSE

Source

Bool.or <- function(first: logical, second: logical) -> logical

Whether either is TRUE. Both arguments are evaluated, unlike with ||.

Bool.or(TRUE, FALSE)
#> TRUE

Source

Bool.not <- function(value: logical) -> logical

The opposite value.

List.keep_if(list(1L, 2L, 3L), function(x) Bool.not(Num.is_even(x)))
#> list(1L, 3L)

Source

Bool.is_eq <- function<T>(first: T, second: T) -> logical

Whether two values are equal by identical(), the library’s equality. An integer and a double are never identical, so Bool.is_eq(1L, 1) is FALSE, and a dictionary or set compares without regard to order.

Bool.is_eq(Set.from_list(list(1L, 2L)), Set.from_list(list(2L, 1L)))
#> TRUE

Source

Bool.is_not_eq <- function<T>(first: T, second: T) -> logical

Whether two values differ by identical().

Bool.is_not_eq(list(1L), list(2L))
#> TRUE

Source