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
#lang racket | |
;; hello world in Racket | |
;; comments begin with ; | |
;; some people like to use ;; | |
;; function application is done by surrounding the function name and arguments in parens | |
;; | |
;; if you have seen languages like Python or JavaScript, f(a,b,c) is (f a b c) in scheme | |
(displayln "Hello, world!") |
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
down vote | |
import time | |
def timeout(f, k, n): | |
last_time = [time.time()] | |
count = [0] | |
def inner(*args, **kwargs): | |
distance = time.time() - last_time[0] |
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 qualified Prelude | |
import Prelude hiding (show) | |
class Show a where | |
show :: a -> Text | |
instance Show a => Show [a] where | |
show xs = append ("[", append ((showList xs), "]")) where | |
showList (x:[]) = show x |
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
function offile() { | |
IFS=''; | |
(while read -r line | |
do | |
file "$line" 2> /dev/null; | |
done <<< $(/usr/bin/ls)) | grep "$1" | tr -s ' '; | |
} | |
#lol gvim -p $(offile ASCII | cut -d ':' -f 1 | sed ':a;N;$!ba;s/\n/ /g') |
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
addn = (n) -> | |
() -> | |
n = n + 1 | |
n | |
add1 = addn 1 | |
console.log(add1()) | |
console.log(add1()) | |
console.log(add1()) | |
console.log(add1()) |
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 Control.Monad | |
import Data.Ratio | |
data FakeRatio = FakeRatio { numr :: Int, denom :: Int} deriving (Show) | |
data SBTriple = SBTriple { left :: FakeRatio, | |
mid :: FakeRatio, | |
right :: FakeRatio} | |
data Directions = TLeft | TRight deriving (Show) |
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 Control.Monad | |
data LSymbol = LRule Char | LDeriv String | |
type Alphabet = [LSymbol] | |
type Axiom = [LSymbol] | |
-- a production is a finite mapping of LSymbol -> LSymbol | |
-- if no production exists for a given LSymbol on the LHS of a Production |
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
from math import log | |
def calcShannonEnt(dataSet): | |
numEntries = len(dataSet) | |
labelCounts = {} | |
for featVec in dataSet: | |
currentLabel = featVec[-1] | |
if currentLabel not in labelCounts.keys(): | |
labelCounts[currentLabel] = 0 | |
else: |
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 Control.Monad | |
enumerate xs = zip [1..] xs | |
dlists :: [a] -> [(a, [a])] | |
dlists xs = [(x, [y | (j, y) <- enumerate xs, j /= i]) | (i, x) <- enumerate xs] | |
permute (x:y:[]) = [y:x:[], x:y:[]] | |
permute xs = let difflist = dlists xs | |
in join [map (i:) (permute d) | (i, d) <- difflist] |
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
{-# LANGUAGE GADTs, FlexibleInstances #-} | |
import Graphics.Gloss | |
import Graphics.Gloss.Data.Vector | |
import LSystem | |
data PlantInstruction a where | |
DrawForward :: PlantInstruction a | |
TurnLeft :: (Show a, Num a) => a -> PlantInstruction a | |
TurnRight :: (Show a, Num a) => a -> PlantInstruction a |
OlderNewer