Skip to content

Instantly share code, notes, and snippets.

PKGCONFIG_DIR = /usr/local/lib/pkgconfig
foxc.pc: foxc.pc.erb
echo "generate .pc.erb -> .pc"
erb foxc.pc.erb > foxc.pc
clean:
rm foxc.pc
distclean: clean
default:
echo "(+ 1 2) (+ 10 3)" | ruby tlisp.rb
#include <stdio.h>
#include <stdlib.h>
void f(int *cands, int *tmp, int life, int i, int size){
if(life==0){
for(int i=0;i<size;i++){
printf("%d", tmp[i]);
putchar(i==size-1 ? '\n' : ',');
}
}
task :graph do
sh <<SH
gosh indented-to-dot.scm indented.txt > a.dot
dot -Tpng a.dot > a.png
SH
end
task :default => [:graph]
(use gauche.experimental.ref)
(use util.match)
(use gauche.experimental.lamb)
(use file.filter)
(define-class <node> ()
[(item :init-keyword :item)
(children :init-keyword :children)])
(define (make-node e)
(use srfi-42)
(sum-ec (: i 1 1000) (if (or (zero? (modulo i 3)) (zero? (modulo i 5)))) i)
(use srfi-1)
(use srfi-42)
(define (f n)
(let1 sources (list-ec (: a 2 (+ n 1)) (: b 2 (+ n 1)) (expt a b))
(length (delete-duplicates sources))))
(f 5) ; => 15
(f 100) ; =>
(use gauche.experimental.lamb)
(define (flatten* tree :optional (r '()))
(fold (^ (x r*) (if (list? x) (flatten* x r*) (cons x r*)))
r tree))
(define flatten (compose reverse flatten*))
(flatten '((((1 ((2 (((3 ((4)))))))))))) ; => (1 2 3 4)
(use util.combinations)
(use gauche.experimental.lamb)
(use srfi-1)
(load "./util.scm")
;;; util
(define (uniq? xs)
(let1 u (delete-duplicates xs)
(and (= (length xs) (length u)) u)))
(define-syntax snlet
(syntax-rules (=)
[(_ x = val rest ...)
(let ((x val))
(snlet rest ...))]
[(_ body)
body]))
(snlet foo = 1
bar = 2