Skip to content
Snippets Groups Projects
Select Git revision
  • 6d6f9a42272c213e8852b2803f39843710f20a13
  • dev default protected
  • prod protected
  • 1.0.58
  • 1.0.57
  • 1.0.52
  • 1.0.56
  • 1.0.51
  • 1.0.50
  • 1.0.33
  • 1.0.32
  • 1.0.31
  • 1.0.30
  • 1.0.29
  • 1.0.28
  • 1.0.27
  • 1.0.26
  • 1.0.25
  • 1.0.24
  • 1.0.23
  • 1.0.22
  • 1.0.21
  • 1.0.20
23 results

Company.php

Blame
  • slice_utils.go 1.10 KiB
    package slice_utils
    
    import (
    	"github.com/thoas/go-funk"
    )
    
    func MinimumFloat64(values []float64) (min float64) {
    	for index, value := range values {
    		if index == 0 || value < min {
    			min = value
    		}
    	}
    	return
    }
    
    // Intersection Finds the intersection between two integer arrays
    func Intersection(a, b []int64) (c []int64) {
    	m := make(map[int64]bool)
    
    	for _, item := range a {
    		m[item] = true
    	}
    
    	for _, item := range b {
    		if _, ok := m[item]; ok {
    			c = append(c, item)
    		}
    	}
    	return
    }
    
    func RemoveStringAtIndex(s []string, index int) []string {
    	return append(s[:index], s[index+1:]...)
    }
    
    func ElementExists(in interface{}, elem interface{}) (bool, int) {
    	idx := funk.IndexOf(in, elem)
    	return idx != -1, idx
    }
    
    func FilterNonZero(arr []int64) []int64 {
    	// Filter out the zero numbers
    	nonZeroNumbers := funk.Filter(arr, func(number int64) bool {
    		return number != 0
    	}).([]int64)
    	return nonZeroNumbers
    }
    
    func FilterNonEmptyString(arr []string) []string {
    	// Filter out empty strings
    	nonEmptyStrings := funk.Filter(arr, func(value string) bool {
    		return value != ""
    	}).([]string)
    	return nonEmptyStrings
    }