Skip to content

Instantly share code, notes, and snippets.

View abeaumont's full-sized avatar

Alfredo Beaumont abeaumont

View GitHub Profile
USING: kernel io.files io.encodings.binary crypto.xor ;
IN: crypt
: crypt ( path key -- str )
[ binary file-contents ] dip xor-crypt ;
module: toandfro
define function group
(sequence :: <sequence>,
n :: <integer>)
=> (newseq :: <sequence>)
map(method(i) copy-sequence(sequence, start: n * i, end: n * (i + 1)) end,
range(below: floor/(sequence.size, n)));
end function group;
: toandfro ( sequence n -- string )
group [ odd? [ reverse ] when ] map-index
flip concat >string ;
module: majority
define function winner (votes :: <collection>)
let winner
= reduce1(method (a, b) if (a.last > b.last) a else b end end,
map(method (candidate)
pair(candidate, size(choose(curry(\=, candidate), votes)));
end,
remove-duplicates(votes)));
unless (zero?(round/(winner.tail, votes.size)))
@abeaumont
abeaumont / project_manager.rst
Created December 18, 2011 11:32 — forked from waywardmonkeys/project_manager.rst
Rethinking the OD project manager

Rethinking the Project Manager

Problem

The current project manager as a variety of problems that we would like to solve. These include:

  • It combines install with build. Everything is built and installed
@abeaumont
abeaumont / split-test.dylan
Created February 6, 2012 21:05
split bug
module: split-test
define function main(name, arguments)
format-out("%d %d\n",
size(split("a b c ", " ", remove-if-empty: #f)),
size(split("a b c ", " ", remove-if-empty: #t)));
exit-application(0);
end function main;
main(application-name(), application-arguments());
@abeaumont
abeaumont / self-describing-sequence.dylan
Last active December 12, 2015 06:38
Golomb sequence
module: self-describing-sequence
define constant <integer-vector> = limited(<simple-vector>, of: <integer>);
define function golomb
(golomb-sequence :: <integer-vector>, n :: <integer>)
=> (fn :: <integer>)
without-bounds-checks
when(golomb-sequence[n - 1] = 0)
golomb-sequence[n - 1] := %golomb(golomb-sequence, n);
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int _golomb(vector<int>& golomb_values, int n);
int golomb(vector<int>& golomb_values, int n) {
if (golomb_values.size() < n) {
@abeaumont
abeaumont / byte-vector-test.dylan
Created March 22, 2013 15:22
OpenDylan's <byte-vector> bug
module: byte-vector-test
define library byte-vector-test
use common-dylan;
use io;
end library;
define module byte-vector-test
use common-dylan, exclude: { format-to-string };
use byte-vector;
@abeaumont
abeaumont / results.org
Last active December 15, 2015 08:09
shootout benchmark result comparison for dylan
benchmarkbest* resultdylantimes
n-body16.165162.35110.043365
fannkuch-redux32.0811301.82540.579315
fasta3.56474.40120.875701
spectral-norm6.010156.59426.055574
mandelbrot (N=1600)0.2733.47712.736264
k-nucleotide (N=2.5M)3.231159.23949.284742
binary-trees8.505184.70721.717460