Beispiel #1
0
// Return the nth digit of 1234567891011121314151617....
func Digit(posit int) string {
	g := AllDigits()
	s := functional.Slice(g, posit, -1)
	var r rune
	s.Next(&r)
	g.Close()
	return string(r)
}
Beispiel #2
0
func main() {
	s := fibonacci()
	s = functional.Join(functional.Count(), s)
	s = functional.Map(
		functional.NewMapper(computeRatio),
		s,
		&fibWithIndex{0, new(big.Int)})

	// Index and ratio from 40th up to 49th fibonacci number.
	s = functional.Slice(s, 40, 50)
	var results []ratioWithIndex
	functional.AppendValues(s, &results)
	fmt.Println(results)
}
Beispiel #3
0
func main() {
	orig := make([]int, 100)
	for i := range orig {
		orig[i] = i
	}

	// Return the 10000th up to the 10010th element of the power set of
	// {0, 1, .. 99}.
	// This entire power set would have 2^100 elements in it!
	s := functional.Slice(Power(orig), 10000, 10010)
	result := make([]int, len(orig))
	for s.Next(&result) {
		fmt.Println(result)
	}
}