Skip to content

Instantly share code, notes, and snippets.

@e-monson
e-monson / sillytext.pl
Last active August 29, 2015 14:17
This generates silly text based on a given text file. Based on http://www.cs.princeton.edu/courses/archive/spr05/cos126/assignments/markov.html Usage: ./sillytext.pl <k-gram length> <iterations> <your text file>
#!/usr/bin/env perl
use strict;
use warnings;
#use criticism 'brutal';
use File::Open qw(fopen);
use Data::Munge;
my $k = shift; # k-gram length
my $n = shift; # number of iterations
my $file = shift;
@e-monson
e-monson / kmeans.exs
Created August 9, 2015 16:29
Implementing k-means in Elixir (unfinished)
defmodule Kmeans do
def test_points do
# This just outputs 100 random points for testing purposes
Stream.repeatedly(fn -> :random.uniform(100) end)
|> Stream.chunk(3)
|> Enum.take(100)
|> Enum.map(&List.to_tuple/1)
end
def point_range(list) when is_list(list) do