pancake

package module
v0.0.0-...-935e4f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2017 License: MIT Imports: 3 Imported by: 1

README

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

Documentation

Overview

pancake contains a few helper functions for flattening multidimensional slices of certain types. It currently supports string, int, and float64.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float64s

func Float64s(a interface{}) ([]float64, error)

Float64s takes a multidimensional slice of float64 and flattens it into a 1-dimensional slice of float64 in row major order.

func Ints

func Ints(a interface{}) ([]int, error)

Ints takes a multidimensional slice of ints and flattens it into a 1-dimensional slice of ints in row major order.

func Strings

func Strings(a interface{}) ([]string, error)

Strings takes a multidimensional slice of strings and flattens it into a 1-dimensional slice of strings in row major order.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL