vosmith / pancake

Utility functions for to flatten multi-dimensional slices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pancake

Pancake is a very simple package written in Go to flatten multidimensional slices. Currently it support string, int, and float64 slices.

Installation

go get github.com/vosmith/pancake

Usage

package main

import (
  "github.com/vosmith/pancake"
  "fmt"
)

func main() {
  // Create a 2-dimensional slice of strings
  arr := [][]string{
		{"a","b","c"},
		{"d","e","f"},
		{"g","h","i"},
		{"j","k","j"}}

  // Flatten it
	arr2, err := pancake.Strings(arr)
  if err != nil {
    panic(err)
  }

  // See the results
  fmt.Println(arr2)
  // >>> [a b c d e f g h i j k j]
}

Future plans

  • Support all primitive data types (bool, byte, chan, func)
  • Support interface?
  • Column-major Support
  • Benchmarks

About

Utility functions for to flatten multi-dimensional slices

License:MIT License


Languages

Language:Go 100.0%