Should Ludus have a linked list collection type? #117

Closed
opened 2025-06-11 22:26:05 +00:00 by scott · 1 comment
Owner

It's so fundamental. Consider the following:

fn cons {
  () -> nil
  (x) -> (x, nil)
  (x, y) -> (x, y)
}

fn car ((x, _)) -> x

fn cdr ((_, y)) -> y

fn llist (...xs) -> foldr (cons, xs)

llist (1, 2, 3, 4) & => (4, (3, (2, (1, nil))))

On the one hand, it's an easy and simple set of functions, but also: llist is a stupid name, I need a new name for this, and it would be useful to have a more nicely printed version of the thing? But also, when would you use this, other than how I did today, which was explaining the convergence between stacks and linked lists.

It's so fundamental. Consider the following: ``` fn cons { () -> nil (x) -> (x, nil) (x, y) -> (x, y) } fn car ((x, _)) -> x fn cdr ((_, y)) -> y fn llist (...xs) -> foldr (cons, xs) llist (1, 2, 3, 4) & => (4, (3, (2, (1, nil)))) ``` On the one hand, it's an easy and simple set of functions, but also: `llist` is a stupid name, I need a new name for this, and it would be useful to have a more nicely printed version of the thing? But also, when would you use this, other than how I did today, which was explaining the convergence between stacks and linked lists.
Author
Owner

Added exactly this!

Added exactly this!
scott closed this issue 2025-06-13 16:17:39 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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: twc/ludus#117
No description provided.