File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1818# @author https://github.com/SuperFola
1919(let find (fun (_L _x) (builtin__list:find _L _x)))
2020
21+ # @brief Search if an element is in a List
22+ # @details The original list is not modified
23+ # @param list the List to search in
24+ # @param value the element to search
25+ # =begin
26+ # (list:contains? [1 2 3] 1) # true
27+ # (list:contains? [1 2 3] 0) # false
28+ # =end
29+ # @author https://github.com/SuperFola
30+ (let contains? (fun (_L _x) (!= -1 (find _L _x))))
31+
2132# @brief Get a slice from a List
2233# @details The original list is not modified
2334# @param list the list to reverse
Original file line number Diff line number Diff line change 2323
2424 (test:eq (builtin__list:setAt a 0 5) (list:setAt a 0 5)) })
2525
26+ (test:case "contains?" {
27+ (test:expect (list:contains? [1 2 3] 1))
28+ (test:expect (not (list:contains? [1 2 3] "1")))
29+ (test:expect (list:contains? ["1" "2" "3"] "1")) })
30+
2631 (test:case "size" {
2732 (test:eq (list:size []) 0)
2833 (test:eq (list:size [1 2 3]) 3) })
You can’t perform that action at this time.
0 commit comments