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 new list methods #94

Closed
ospencer opened this issue Mar 22, 2020 · 4 comments
Closed

Add new list methods #94

ospencer opened this issue Mar 22, 2020 · 4 comments

Comments

@ospencer
Copy link
Member

ospencer commented Mar 22, 2020

Let's add methods for these:

some # checks that at least one item in the list is true for a given condition
nth # gets the nth item in the list
filter
reject # opposite of filter
count # counts how many elements satisfy a given condition
hd # gets the first item in the list
tl # returns the list without the first item
flatten # takes a list of lists and combines them into a single list
insert # takes a list, item, index. inserts the item at the index-th position
rotate # takes a list, count. item at count-th position becomes the first item. should work for negative counts as well
uniq
part # takes a list and and a number. returns a tuple containing the first n items and the rest of the list
@ospencer
Copy link
Member Author

Removed every since that rename has already been done.

@designsbysm
Copy link
Contributor

It looks like several of these functions should be included with Array.

@ospencer
Copy link
Member Author

@JacobGinsparg is currently taking this on, and I think it's almost complete?

@ospencer
Copy link
Member Author

I removed sort and sortBy from this in favor of #125.

I also added a new method, part, since it seems like it'd be useful for rotate.

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

No branches or pull requests

2 participants