Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Nth function #144

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add the Nth function #144

wants to merge 3 commits into from

Conversation

mariari
Copy link
Member

@mariari mariari commented Nov 7, 2024

Useful definition that someone may want to call

lukaszcz and others added 2 commits November 6, 2024 18:23
The naming on this is probably bad, I'd assume `head` would return
Maybe, and you'd have a headDefault or something for a default head
@mariari
Copy link
Member Author

mariari commented Nov 7, 2024

I'm unsure if my index's for nth is right

Stdlib.Prelude> (nth 1 [1;2;3;4;5])
just 2
Stdlib.Prelude> (nth 0 [1;2;3;4;5])
just 1
Stdlib.Prelude> (nth 7 [1;2;3;4;5])
nothing

Copy link

@heueristik heueristik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor request to support the named syntax

@@ -96,6 +92,10 @@ drop {A} : (elemsNum : Nat) -> (list : List A) -> List A
| (suc n) (x :: xs) := drop n xs
| _ xs := xs;

--- Take the nth value of a ;List;
nth {A} : Nat -> List A -> Maybe A

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the named syntax to allow people using it in case the want to?

@mariari mariari force-pushed the mariari/nth-function branch from 0f7ce30 to 386b38e Compare November 7, 2024 09:51
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.

3 participants