Skip to content

Added a new list exercise to Section 3.4#87

Merged
stefan-hoeck merged 1 commit into
stefan-hoeck:mainfrom
Liable5607:list-exercise-3.iv
Jul 21, 2025
Merged

Added a new list exercise to Section 3.4#87
stefan-hoeck merged 1 commit into
stefan-hoeck:mainfrom
Liable5607:list-exercise-3.iv

Conversation

@Liable5607

@Liable5607 Liable5607 commented Jul 19, 2025

Copy link
Copy Markdown
Contributor

At the beginning of 6.iii, in the part discussing Vect concatenation, there was a reference to list concatenation:

It is possible to concatenate two Lists with the (++) operator. Surely, this should also be possible for Vect. But Vect is indexed by its length, so we have to reflect in the types exactly how the lengths of the inputs affect the lengths of the output. Here's how to do this:

I implemented that as an exercise (and checked it against Prelude.List.(++)) and thought that was interesting. It seemed to fit better in Section 3.iv though. I do think because there aren't a lot of List recursion exercises there, having another one is nice.

@Liable5607 Liable5607 changed the title Added a new list exercise to 3.iv Added a new list exercise to Section 3.4 Jul 20, 2025
@stefan-hoeck stefan-hoeck merged commit a4aeb17 into stefan-hoeck:main Jul 21, 2025
2 checks passed
@stefan-hoeck

Copy link
Copy Markdown
Owner

Thanks. It's definitely good to have more basic exercises with recursion. Once people arrive at "Recursion and Folds", it would be another good exercise to re-implement many of the recursive functions from other chapters in a tail-recursive manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants