Skip to content

Instantly share code, notes, and snippets.

@tomonacci
tomonacci / build.sc
Last active July 20, 2022 13:42
Using Twitter Scrooge with Mill
import scalalib._
import mill._
import mill.define.Sources
import mill.api.PathRef
import $ivy.`com.twitter::scrooge-generator:19.11.0`
object example extends Cross[ExampleModule]("2.12.8")
class ExampleModule(val crossScalaVersion: String) extends CrossSbtModule {
@tomonacci
tomonacci / sets-of-sets.gosh
Created April 24, 2016 00:44
Sets of sets
(use srfi-113)
(define (main args)
(let ([a (list->set equal-comparator '(0 1))]
[b (list->set equal-comparator '(1 0))])
#?=(set=? a b)
#?=(set-size (set set-comparator a b)))
(let ([a (list->set equal-comparator '((2 . 1) (1 . 1) (0 . 2) (0 . 0)))]
[b (list->set equal-comparator '((2 . 1) (1 . 1) (0 . 0) (0 . 2)))])
#?=(set=? a b)
@tomonacci
tomonacci / _evince
Created December 28, 2011 06:29
Zsh completion for evince
#compdef evince
local arguments
arguments=(
'(-h --help --help-all --help-sm-client --help-gtk)'{-h,--help}'[show help options]'
'(-h --help --help-sm-client --help-gtk)--help-all[show all help options]'
'(-h --help --help-all --help-gtk)--help-sm-client[show session management options]'
'(-h --help --help-all --help-sm-client)--help-gtk[show GTK+ Options]'
'--sm-client-disable[disable connection to session manager]'
'--sm-client-state-file=[specify file containing saved configuration]'
@tomonacci
tomonacci / wave.scm
Created August 19, 2011 09:09
新・物理入門問題演習 111頁
(use gauche.threads)
(use math.const)
(use srfi-42)
(use gl)
(use gl.glut)
(define a 40)
(define A 10)
(define f 1)
; v = 3/4 fa
@tomonacci
tomonacci / herbert-parser.scm
Created March 15, 2011 16:05
parsing Herbert programs
;;; herbert-parser.scm - parsing Herbert programs
;;;
;;; Usage (the result is indented manually):
;;;
;;; % cat test.hervert
;;; a(X,Y,Z):b(X-12+13-Y+Z,X)ccsslr
;;; b(X):cccc
;;; c:s
;;; ss
;;; % gosh herbert-parser.scm < test.hervert
@tomonacci
tomonacci / sort.scm
Created February 20, 2011 04:32
All sorts of sorting algorithms written in Scheme (Gauche)
(use srfi-27)
(use srfi-42)
(define-macro (swap! a b)
(let1 t (gensym)
`(let1 ,t ,a
(set! ,a ,b)
(set! ,b ,t))))
(define (bubble-sort v)
<!DOCTYPE html>
<html>
<head>
<title>Function space</title>
<style>
canvas {
float: left;
margin: 10px;
}
</style>
<!DOCTYPE html>
<html>
<head>
<title>Koch snowflake</title>
<style type='text/css'>
input {
width: 4em;
}
</style>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.4.3.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<title>Cardioid</title>
<style>
input {
width: 3em;
}
</style>
<script>
@tomonacci
tomonacci / fiber-prime.rb
Created February 23, 2010 06:37
Prime number enumerator using Fiber
def fiber_manager(j, g)
fiber_manager((nf = Fiber.new do |i, f|
print "#{i} "
while (n = f.resume) % i == 0; end
Fiber.yield(n)
loop do
n = f.resume
Fiber.yield(n) if n % i != 0
end
end).resume(j, g), nf)