Git Product home page Git Product logo

go-slices's Introduction

Tideland Go Slices

GitHub release GitHub license Go Module GoDoc Workflow Go Report Card

Description

Tideland Go Slices provides a set of functions for the processing of types slices based on generics and higher-order functions. This processing contains tests, mappings, filterings, concatings, deleting, filtering, folding and many more. Opposite to the standard library of Go with similiar functions like e.g. Sort() will not work on the same slice. All functions return new created slices, even if a variable operation would have no effect.

Contributors

go-slices's People

Contributors

themue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

isgasho

go-slices's Issues

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

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 dropping functions

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

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 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

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 delete function

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

Add shuffle function

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

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?

Fix build and tests

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

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.