This file contains hidden or 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
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
module WorkspaceOverviewPopup where | |
import Data.Maybe | |
import Control.Monad | |
import XMonad | |
import qualified XMonad.StackSet as W | |
import XMonad.Layout.LayoutModifier | |
import XMonad.Util.Font |
This file contains hidden or 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
from __future__ import division | |
## Equations: | |
# x(t+h) = x(t) + 1/2 (F1 + F2) | |
# F1 = h*f(t,x) | |
# F2 = h*f(t+h, x+h*f(t,x)) | |
def rungekutta(f, a, b, x0, iterations): | |
h = (b - a) / iterations | |
x = x0 |
This file contains hidden or 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
replaceEs :: String -> String | |
-- One way | |
replaceEs ('e':cs) = 'a' : replaceEs cs | |
replaceEs (c:cs) = c : replaceEs cs | |
replaceEs [] = [] | |
-- Or another | |
replaceEs [] = [] | |
replaceEs (c:cs) = | |
case c of |
This file contains hidden or 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
m <- matrix(c(1, 0, 0, | |
0, 4, 0, | |
0, 0, 2), ncol=3, byrow=T) |
This file contains hidden or 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
# RISK Attack Simulation | |
attack <- function(na, nb) { | |
die <- 1:6 | |
while (na > 0 & nb > 0) { | |
attackers <- min(na, 3) | |
defenders <- min(nb, 2) | |
fights <- min(attackers, defenders) | |
hit_a <- sort(sample(die, attackers), decreasing=T)[1:fights] |
This file contains hidden or 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
{ | |
(* A position in a file is identified as a (line,column) : int * int *) | |
type position = int * int | |
(* Lexical errors have some error message and a position in the file *) | |
exception LexicalError of string * position (* (message, (line, column)) *) | |
(* While scanning the file, line numbers and the character offset (the integer | |
position for the character in the file) for each beginning line are kept |
This file contains hidden or 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
local | |
fun fbstr i = | |
case (i mod 3 = 0, i mod 5 = 0) of | |
(true , true ) => "FizzBuzz" | |
| (true , false) => "Fizz" | |
| (false, true ) => "Buzz" | |
| (false, false) => Int.toString i | |
fun fizzbuzz' (n, j) = |
This file contains hidden or 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(simple2). | |
-export([start/0]). | |
-define(PORT, 33333). | |
start() -> | |
{ok, spawn(fun listener/0)}. | |
listener() -> | |
ChatMaster = spawn(fun() -> chatmaster(dict:new()) end), | |
{ok, ListenSocket} = gen_tcp:listen(?PORT, [binary, {active, true}]), |
This file contains hidden or 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(simple_chatserver). | |
-export([start/0]). | |
-define(PORT, 33333). | |
% External API function for starting chat server | |
start() -> | |
% Start a process for coordinating communication between clients | |
CoordinatorPid = spawn(fun() -> coordinator(dict:new()) end), | |
% Listen to a TCP socket and start a process that accepts incoming |
This file contains hidden or 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
datatype bentSpil = BentSlutter of int | |
| BentSpiller of ingeSpil list | |
and ingeSpil = IngeSlutter of int | |
| IngeSpiller of bentSpil list | |
(* bent8 *) | |
val inge3 = IngeSpiller [ BentSlutter 0 ] | |
val inge4 = IngeSpiller [ BentSlutter 0, BentSlutter 1 ] |