- Find retrieves the first, or last, list value that returns a true when passed to a predicate procedure
- `last?` defaults to `#f`, thus returning the first truthy value. A `#t` setting for `last?` will return the _last_ truthy value (it will make the procedure right associative)
- `nomatch` defines the value to be returned if _no_ list values are found to be truthy. The default 'nomatch' value is `#f`
- Position retrieves the first, or last, list index that returns a true when passed to a predicate procedure
- `last?` defaults to `#f`, thus returning the first truthy value. A `#t` setting for `last?` will return the _last_ truthy value (it will make the procedure right associative)
- `nomatch` defines the value to be returned if _no_ list values are found to be truthy. The default 'nomatch' value is `#f`
- Sublists are not evaluated. If the given list contains no atoms, but only other lists, `#t` will be returned regardless of the contents of the sublists
;; alike returns a boolean representing whether or not
;; the items in the list are of the same type
;;
;; (alike? [list]) => bool
;; (list::alike? [list]) => bool
;;
;; ex: (alike? [1 2 3 4]) => #t
;; (alike? [1 2 "3" 4]) => #f
;; (alike? [[1 2] ["a" "b"] []]) => #t
;; (alike? []) => #t
;; ex: (list::alike? [1 2 3 4]) => #t
;; (list::alike? [1 2 "3" 4]) => #f
;; (list::alike? [[1 2] ["a" "b"] []]) => #t
;; (list::alike? []) => #t
;;
;; - A null list returns #t
;; - Sublists are not evaluated, if all items in a list
@ -196,4 +196,13 @@
(else (alike-loop (cdr lst) typ)))))
(alike-loop l (type (car l))))))))
; vim: ts=2 sw=2 expandtab ft=scheme
(define _USAGE [
["reduce" "(list::reduce [procedure] [list] [init: value]) => value\n\n`reduce`. This version of reduce is left associative and was added to this module before `reduce` was present in the std library. It remains here for historical reasons, but the builtin should be favored."]
["last" "(list::last [list]) => value\n\n`last` retrieves the last value in the list, and is thus the opposite of the built-in `car`"]
["find" "(list::find [procedure] [list] [[last?: bool]] [[nomatch: value]]) => number|nomatch: value\n\n`find` retrieves the first, or last, list value that returns `#t` when pased to a predicate procedure.\n\n`last?` defaults to `#f`, thus returning the first truthy value. A `#t` setting for `last?` will return the last truthy value (it will make the procedure right associative).\n\n`nomatch` defines the value to be returned if no list values are found to be truthy. The default `nomatch` value is `#f`."]
["position" "(list::position [procedure] [list] [[last?: bool]] [[nomatch: value]]) => number|nomatch: value\n\n`position` retrieves the first, or last, list index that returns `#t` when pased to a predicate procedure.\n\n`last?` defaults to `#f`, thus returning the first truthy value. A `#t` setting for `last?` will return the last truthy value (it will make the procedure right associative).\n\n`nomatch` defines the value to be returned if no list values are found to be truthy. The default `nomatch` value is `#f`."]
["unique" "(list::unique [list]) => list\n\n`unique` returns a set/unique-list from the given list"]
["cadr" "(list::cadr [list]) => value\n\n`cadr` returns the car of the cdr of the given list"]
["alike?" "(list::alike [list]) => bool\n\n`alike?` returns a boolean representing whether or not the items in the list are of the same type"]])