This file contains 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
import Data.Bits | |
import Data.Char | |
import Data.Word | |
import qualified Data.Trie as T | |
import qualified Data.ByteString as BS | |
cipherText :: [Int] | |
cipherText = [79,59,12,2,79,35,8,28,20,2,3,68,8,9,68,45,0,12,9,67,68,4,7,5,23,27,1,21,79,85,78,79,85,71,38,10,71,27,12,2,79,6,2,8,13,9,1,13,9,8,68,19,7,1,71,56,11,21,11,68,6,3,22,2,14,0,30,79,1,31,6,23,19,10,0,73,79,44,2,79,19,6,28,68,16,6,16,15,79,35,8,11,72,71,14,10,3,79,12,2,79,19,6,28,68,32,0,0,73,79,86,71,39,1,71,24,5,20,79,13,9,79,16,15,10,68,5,10,3,14,1,10,14,1,3,71,24,13,19,7,68,32,0,0,73,79,87,71,39,1,71,12,22,2,14,16,2,11,68,2,25,1,21,22,16,15,6,10,0,79,16,15,10,22,2,79,13,20,65,68,41,0,16,15,6,10,0,79,1,31,6,23,19,28,68,19,7,5,19,79,12,2,79,0,14,11,10,64,27,68,10,14,15,2,65,68,83,79,40,14,9,1,71,6,16,20,10,8,1,79,19,6,28,68,14,1,68,15,6,9,75,79,5,9,11,68,19,7,13,20,79,8,14,9,1,71,8,13,17,10,23,71,3,13,0,7,16,71,27,11,71,10,18,2,29,29,8,1,1,73,79,81,71,59,12,2,79,8,14,8,12,19,79,23,15,6,10,2,28,68,19,7,22,8,26,3,15,79,16,15,10,68,3,14,22,12,1,1,20,28,72,71,14 |
This file contains 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
import Data.List | |
numbers = [1..10^6] | |
convRadix :: (Integral b) => b -> b -> [b] | |
convRadix n = | |
unfoldr (\b -> if b == 0 then Nothing else Just (b `mod` n, b `div` n)) | |
isPalindrome10 n = sn == (reverse sn) | |
where sn = show n |
This file contains 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
import Data.List | |
numbers = [3..10^6] -- arbitrary guess | |
convRadix :: (Integral b) => b -> b -> [b] | |
convRadix n = | |
unfoldr (\b -> if b == 0 then Nothing else Just (b `mod` n, b `div` n)) | |
fact n = facti n 1 | |
where facti 0 a = a |
This file contains 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
// Attempt at defining a mapping interface for Go | |
package main | |
import ( | |
"fmt"; | |
"container/list" | |
) | |
func Map (l *list.List, f func (int) int) *list.List { |
This file contains 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 main | |
import ( | |
"fmt"; | |
) | |
func worker (i int, c chan bool) () { | |
fmt.Printf("%d\n", i); | |
c <- true; | |
} |
This file contains 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
-module(tester). | |
-export([init/0, test/0]). | |
init() -> | |
ets:new(?MODULE, [named_table, public]), | |
ets:insert(?MODULE, [{K, foo} || K <- lists:seq(1,10000)]). | |
test() -> |
This file contains 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
%% Naive factorial, not tail recursive | |
%% (caveat, not tested) | |
fac(0) -> 1; | |
fac(N) when is_integer(N), N > 0 -> | |
RecCall = fac(N-1), %% The recursive call is not the last thing that happens | |
RecCall * N. % This is the last thing that happens | |
%% Tail recursive variant: |
This file contains 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
#include <stdlib.h> | |
#include <stdio.h> | |
int | |
main(int argc, char **argv) | |
{ | |
int i = 42; | |
void *pt = &i; | |
int *ip = (int*) pt; |
This file contains 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
let rec even x = | |
match x with | |
| 0 -> true | |
| 1 -> false | |
| _ -> odd (x-1) | |
and odd x = | |
match x with | |
| 1 -> true | |
| 0 -> false | |
| _ -> even (x-1);; |
This file contains 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
(* Disjoint Set implementation in Ocaml. | |
* The implementation here is written by Jesper Louis Andersen, but is | |
* loosely based on an equivalent in MLton: | |
* | |
* Copyright (C) 2009 Matthew Fluet. | |
* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh | |
* Jagannathan, and Stephen Weeks. | |
* | |
* MLton is released under a BSD-style license. | |
* See the file MLton-LICENSE for details. |