Code Monkey home page Code Monkey logo

go-generics-example's Introduction

go-generics-example

Example code for Go generics.

Usage

$ go build -gcflags=-G=3

Requirements

Go 1.18 or later

Third-party packages that support Generics

  • Code-Hex/go-generics-cache An in-memory key:value store/cache library written in Go 1.18 generics
  • genkami/dogs Dogs is a library that provides some useful types and functions borrowed from functional languages.
  • makiuchi-d/tuple Definition of n-tuple structs using type parameters.
  • samber/lo ๐Ÿ’ฅ A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)
  • mattn/go-result Something like unwrap in Rust.
  • makiuchi-d/linq LINQ for Go with type parameters.

Advertise

Go ่จ€่ชžใซใ‚„ใฃใฆใใ‚‹ Generics ใฏๆˆ‘ใ€…ใซไฝ•ใ‚’ใ‚‚ใŸใ‚‰ใ™ใฎใ‹

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)

go-generics-example's People

Contributors

1ch0 avatar chiefmatestarbuck avatar code-hex avatar colinking avatar genkami avatar gillesdemey avatar huhaibo avatar kachick avatar makiuchi-d avatar mattn avatar yuchanns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-generics-example's Issues

Ternaryop and Normal Order Evaluation

Normal Order Evaluation is an evaluation strategy in which an expression is evaluated by repeatedly evaluating its leftmost outermost reducible expression. This means that a function's arguments are not evaluated before the function is applied.

In a word, left or right value should be evaluated when it is applied

So this code should be some kind of the following form:

package main

import (
	"fmt"
)

func ternaryOp[T any](s bool, t func() T, f func() T) T {
	if s {
		return t()
	}
	return f()
}

func main() {
	fmt.Println(ternaryOp(4 < 5, func() string {
		fmt.Println("left evaluated")
		return "less"
	}, func() string {
		fmt.Println("right evaluated")
		return "greater"
	}))
}

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.