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

Head function and Composing find #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mariari
Copy link
Member

@mariari mariari commented Nov 7, 2024

find is just filter where we call a maybe head. This topic simply does that.

@mariari mariari force-pushed the mariari/head-maybe branch from c85dd06 to f90a657 Compare November 7, 2024 06:16
Comment on lines 21 to 22
find {A} (predicate : A -> Bool) : (list : List A) -> Maybe A :=
filter predicate >> headMaybe;
Copy link
Contributor

Choose a reason for hiding this comment

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

in a strict language such as juvix this is less efficient than before, because we always traverse the whole list, even if the first element satisfies the predicate

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh true, I forgot about that here, good catch

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this comment alone is enough to just remove the last commit and merge in the headMaybe function alone.

Copy link
Member Author

@mariari mariari Nov 7, 2024

Choose a reason for hiding this comment

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

I've force pushed an update to remove the find commit

@mariari mariari force-pushed the mariari/head-maybe branch from f90a657 to a567cf1 Compare November 7, 2024 09:51
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
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