Giter VIP home page Giter VIP logo

giter's Introduction

giter

did i break the build/tests? Go Reference

i wanted to pass a function an iterator over a map's keys and now I have this.

there is a non-zero chance that:

  1. someone else has already done this, or
  2. this is very non-idiomatic Go.

I'm ok with both.

this whole exercise is somewhat poisoned by how verbose and without-inference go's function literal syntax is ╮ (. ❛ ᴗ ❛.) ╭

usage

package main

import (
	"fmt"

	i "github.com/bkgood/giter"
)

func main() {
	// sum the even numbers in [0, 100)
	x := i.Sum(i.Filter(func(x int) bool { return x%2 == 0 }, i.Range[int](0, 100)))

	// 2450
	fmt.Println(x)

	// build an index of some structs by an id
	type foo struct {
		id   int
		name string
	}

	index := i.Collect( // or just ToMap
		i.MapCollector[int, foo](),
		i.Map(
			func(f foo) i.KVPair[int, foo] {
				return i.KVPair[int, foo]{f.id, f}
			},
			i.Slice([]foo{foo{1, "willy"}})))

	// map[1:{1 willy}]
	fmt.Println(index)
}

things i vaguely want to do

add docs

i'm still getting used to writing godoc stuff; this would be decent practice.

sort out if I can have sized iterators next to unsized ones

if i can see a size, I can preallocate in collection.

other functions

reverse ranges

ranges only ascend now. they should be able to descend.

isn't this slow?

probably? i wouldn't try to write a blas implementation with it. but for typical webby line-of-business type stuff, it is predictably slow, and behaves the same for large and small n.

but if someone did write a blas implementation with this i would be amused.

giter's People

Contributors

bkgood avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.