GithubHelp home page GithubHelp logo

tideland / go-slices Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 1.0 84 KB

Process typed Go slices via generics and higher-order functions.

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%
go golang golang-package higher-order-functions slices

go-slices's People

Contributors

themue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

isgasho

go-slices's Issues

Fix late discoverings

  • Drop DeleteAllWith() as it is just Filter()
  • Move less in IsSortedWith() and SortWith() to first argument position to match other functions

Add merge functions

  • Add Merge(vsa, vsb) appending and sorting vsa and vsb
  • Add UniqueMerge(vsa, vsb) appending, unifying and sorting vsa and vsb
  • Add MergeWith(vsa, vsb, less) appending and sorting vsa and vsb using lessto compare the values
  • Add UniqueMergeWith(vsa, vsb, less) appending, unifying and sorting vsa and vsb using lessto compare the values

Add delete function

  • Add DeleteAllWith(ivs, pred) deleting all values where pred(iv) bool returns true

Add dropping functions

  • Add DropFirst(ivs) removing the first value; returns nil for nil
  • Add DropLast(ivs) removing the last value; returns nil for nil

Compare two slices

Compare the content of two slices in two function:

  • Compare() to compare the elements direct
  • CompareWith() to compare the elements with a helper function, e.g. to compare structs

Open questions:

  • What is the output?

Add sort function

  • Function Sort() is sorting a slice with values implementing the constraints.Ordered constraint
  • Function SortWith() is sorting a slice with the help of a less function
  • Similar functions IsSorted() and IsSortedWith() for testing

Add more delete functions

  • DeleteAll() to delete all occurrence of a value
  • DeleteWith() to delete the first occurrence where pred() returns true
  • DeleteAllWith() to delete all occurrence where pred() returns true

Add unique functions

  • Function Unique() to find only unique values in slice of comparables
  • Function UniqueWith() to find only unique values in any slice with the help of a test function

Fix build and tests

  • Build interprets logging in tests as error
  • Some tests have no descriptions

Add shuffle function

  • Integrate a shuffle function using
rand.Shuffle(len(items), func(i, j int) {
    items[i], items[j] = items[j], items[i]
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.