Skip to content

A place to add some missing filter functions: filterfirst, filtersingle, filterlast, etc.

License

Notifications You must be signed in to change notification settings

bradcarman/FilterHelpers.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FilterHelpers.jl

Build Status Coverage

This package provides some simple functions I often find I would like to have in the Julia language, similar to the find functions (i.e. findfirst, findlast, etc.), which return the object rather than the index. This also includes filtersingle which provides the same functionality as c# Enumerable.Single method.

For example:

    struct Person
        id::Int
        name::String
    end

    brad = Person(1, "Brad")
    julia = Person(1, "Julia")
    audra = Person(2, "Audra")
    ellie = Person(3, "Ellie")

    people = [brad, audra, ellie, julia]

    x = filtersingle(x->x.id == 3, people) #returns the object `ellie`
    x = filtersingle(x->x.id == 1, people) #throws an exception
    x = filterfirst(x->x.id == 1, people) #returns `brad`

About

A place to add some missing filter functions: filterfirst, filtersingle, filterlast, etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages