I hereby claim:
- I am kalexmills on github.
- I am kalexmills2021 (https://keybase.io/kalexmills2021) on keybase.
- I have a public key ASDAjVsDVzqIvRcW6yjynPsMwtNjqwucMs3rA736RD1JVQo
To claim this, I am signing this object:
# Go2Go Snippets | |
To better understand the impact of the Go generics proposal, this repository collects a list of solutions to problems that could benefit from generics and links to implementations that run on [The go2go Playground](https://go2goplay.golang.org). Multiple implementations for the same problem are highly encouraged. Having a variety of solutions to look at and compare will help the community learn about approaches to generics that may and may not be useful. | |
Pull requests are welcome, both for solutions to the problems below and solutions of new problems! Just modify this file to a link to a go2go example that includes a `main` method demonstrating correct usage. Maintainers may run format on your submission and modify the link before merging, but we *will* preserve your original commit in the history. | |
If you are copying from an online source, please make sure 1) you are able to do so and 2) include a link back to the original material. | |
If you see an implementation in this list that you have |
package main | |
// Path represents a looping sequence of points which are interpolated between. | |
// FIXME: this doesn't loop properly at the moment. It will need to be recreated whenever the animation completes. | |
type Path struct { | |
sequence *gween.Sequence | |
points []image.Point | |
idx int | |
} |
I hereby claim:
To claim this, I am signing this object:
-- sqlite3 flavored SQL | |
CREATE TABLE comment ( | |
id INTEGER PRIMARY KEY ASC, | |
parent_id INTEGER, | |
content TEXT NOT NULL, | |
create_time TEXT NOT NULL, | |
is_deleted INTEGER DEFAULT 0, | |
FOREIGN KEY(parent_id) references comment(id) |
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"strings" | |
) | |
func main() { |
import cats._ | |
import cats.data._ | |
import cats.implicits._ | |
import cats.syntax._ | |
import cats.effect._ | |
import cats.effect.concurrent._ | |
import cats.effect.implicits._ | |
import cats.effect.ExitCase._ | |
import cats.arrow.Compose |
/** | |
* Asynchronous CBOR message traffic via tokio / serde. More at https://cbor.io | |
* | |
* Test via `cargo run` and, in a separate terminal test using these messages. | |
* | |
* $ echo '00000017A2616364526561646161826568656C6C6F65776F726C64' | xxd -r -p | nc 127.0.0.1 6142 | |
* $ echo '0000000FA1616D6B68656C6C6F20776F726C64' | xxd -r -p | nc 127.0.0.1 6142 | |
* | |
* First 8 bytes are the length of the data frame, rest is the CBOR message. | |
*/ |
package com.niftysoft.gennit.util | |
import cats._ | |
import cats.implicits._ | |
import scala.annotation.tailrec | |
case class MultiSet[V] private (data: Map[V,Int]) { | |
def filter(f: V => Boolean): MultiSet[V] = MultiSet(data.filter{case(v, mul) => f(v)}) |
import cats.data.Reader | |
import scala.reflect.ClassTag | |
/** | |
* Distribution takes a PFloat and returns an A. | |
*/ | |
type Distribution[A] = Reader[PFloat, A] | |
/** | |
* PFloat represents a Float describing a probability. Its value is always between |