List generation and transformation #74

Open
opened 2024-09-01 19:41:02 +02:00 by liquidev · 0 comments
liquidev commented 2024-09-01 19:41:02 +02:00 (Migrated from github.com)

We should have functions for generating and transforming lists.

-- Generate a list with integers from min to max inclusive.
generate
  min : number
  max : number
  -> list number

-- Produce a new list with each of the elements transformed by f.
map
  l : list T
  f : \T -> U
  -> list U

-- Produce a list with elements that satisfy the given predicate.
filter
  l : list T
  f : \T -> boolean
  -> list T

-- Iterate through all of the list's elements from left to right and reduce them to a single element.
reduce
  l : list T
  init : A
  f : \A, T -> A
  -> A

-- Flatten a nested list by one level.
flatten
  l : list _
  -> list _
We should have functions for generating and transforming lists. ```haku -- Generate a list with integers from min to max inclusive. generate min : number max : number -> list number -- Produce a new list with each of the elements transformed by f. map l : list T f : \T -> U -> list U -- Produce a list with elements that satisfy the given predicate. filter l : list T f : \T -> boolean -> list T -- Iterate through all of the list's elements from left to right and reduce them to a single element. reduce l : list T init : A f : \A, T -> A -> A -- Flatten a nested list by one level. flatten l : list _ -> list _ ```
liquidex added this to the Backlog project 2024-09-13 20:24:03 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: liquidex/rkgk#74
No description provided.