A solver for Towers of Hanoi written in Par. Thanks to faiface for helping me figure out how to handle the recursion and other things I was having some trouble with.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Set<a> = iterative box choice { | |
| .add(a) => self, | |
| .has(a) => (Bool) self, | |
| .remove(a) => self, | |
| } | |
| dec Set.String : [List<String>] Set<String> | |
| def Set.String = [list] do { | |
| let list: List<(String) !> = list.begin.case { | |
| .end! => .end!, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dec Fetch : [String, String, List<(String) String>, String] | |
| Result<Http.Error, (Nat, List<(String) String>) List<Result<Http.Error, String>>> | |
| def Fetch = [method, url, headers, body] chan yield { | |
| catch e => { yield <> .err e } | |
| let try url = Url.FromString(url) | |
| let req = (method, url, headers) Bytes.Reader(body) | |
| let try (status, headers) body = Http.Fetch(req) | |
| let headers = ToStringHeaders(headers) | |
| let body = ToLines(type Http.Error)(body) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Prerequisites: | |
| # - ffmpeg and ffprobe installed (for video processing). | |
| # - upscayl-ncsnn installed (for upscaling). | |
| # Ensure it's in your PATH or adjust the command below. | |
| # - Models optionally downloaded into a 'models' directory in the current working directory (or adjust -m option). | |
| # | |
| # Usage: ./script.sh input.mp4 output.webp [scale] [model] | |
| # - scale: Upscale factor (default: 4, can be 2, 3, or 4). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| goos: linux | |
| goarch: amd64 | |
| pkg: seqread | |
| cpu: AMD Ryzen 9 3900X 12-Core Processor | |
| │ simple.txt │ push.txt │ pull.txt │ | |
| │ sec/op │ sec/op vs base │ sec/op vs base │ | |
| Read-24 245.9n ± 1% 246.2n ± 2% ~ (p=0.725 n=10) 1137.0n ± 2% +362.29% (p=0.000 n=10) | |
| │ simple.txt │ push.txt │ pull.txt │ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Test do | |
| use GenServer | |
| require Logger | |
| def start_link([]) do | |
| GenServer.start_link(__MODULE__, []) | |
| end | |
| def init([]) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package example | |
| type Queue[T any] struct { | |
| push chan T | |
| pop chan T | |
| } | |
| func NewQueue[T any](ctx context.Context) { | |
| q := Queue{ | |
| push: make(chan T), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package iter_test | |
| import ( | |
| "bufio" | |
| "io" | |
| "iter" | |
| "strings" | |
| "testing" | |
| ) |
NewerOlder