query
On this page

optionals

lib.lists.optionals

Docs pulled from | This Revision | about 1 hour ago


Return a list or an empty list, depending on a boolean value.

Inputs

cond

Condition

elems

List to return if condition is true

Type

optionals :: bool -> [a] -> [a]

Examples

lib.lists.optionals usage example

optionals true [ 2 3 ]
=> [ 2 3 ]
optionals false [ 2 3 ]
=> [ ]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

optionals =
    cond:
    elems: if cond then elems else [];