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
Configuring copilot-core-2.1.2... | |
Building copilot-core-2.1.2... | |
Preprocessing library copilot-core-2.1.2... | |
[ 1 of 23] Compiling Copilot.Core.Type.Equality ( src/Copilot/Core/Type/Equality.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Copilot/Core/Type/Equality.o ) | |
[ 2 of 23] Compiling Copilot.Core.Random.Weights ( src/Copilot/Core/Random/Weights.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Copilot/Core/Random/Weights.o ) | |
[ 3 of 23] Compiling Copilot.Core.Type.Dynamic ( src/Copilot/Core/Type/Dynamic.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Copilot/Core/Type/Dynamic.o ) | |
[ 4 of 23] Compiling Copilot.Core.Type ( src/Copilot/Core/Type.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Copilot/Core/Type.o ) | |
[ 5 of 23] Compiling Copilot.Core.Type.Uninitialized ( src/Copilot/Core/Type/Uninitialized.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Copilot/Core/Type/Uninitialized.o ) | |
[ 6 of 23] Compiling Copilot.Core.Type.Show ( src/Copilo |
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
f:: Maybe a -> Maybe b | |
f (Just a) = Just a | |
g:: Maybe a → Maybe b | |
g (Just a) = Just a | |
c = f . 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
function heterogenous_sum_fold(prev, cur, I, a){ | |
if( Object.prototype.toString.call( someVar ) === '[object Array]') { //if it's an array | |
return prev +cur.reduce(heterogeneous_sum_fold); | |
//apply this function recursively. | |
} | |
return prev + cur; // probably everything else. Might error. | |
} | |
Array.reduce(heterogeneous_sum_fold); //how to invoke |
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 Text.ParserCombinators.Parsec | |
main = (getLine >>= \line -> putStrLn . either show show $ ((parse (many digit >>= \d1 -> oneOf ['+','-','/','*'] >>= \f -> many digit >>= \d2 -> return (read d1, (if (f == '+') then (+) else if (f=='-') then (-) else if (f == '*') then (*) else if (f == '/') then (/) else undefined), read d2)) "golf parser"line) >>= \(d1,f,d2)->return (f d1 d2))) |
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 System.Random | |
import Control.Monad | |
main = do | |
let trials = 100000 | |
vals ← collect trials $ zip [1‥7] $ cycle [0] | |
let percents = map (λ(value,amount) → (value,amount / trials)) vals | |
print percents | |
--collect:: Int -> [(Int, Int)] -> IO [(Int, Int)] |
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
matrix_list = [[1,2,3],[4,5,6],[7,8,9]] | |
def lrange(seq): | |
'''returns a generator for the range of a length of a matrix''' | |
return range(len(seq)) | |
def rotateMatrix(matrix_list): | |
'''rotates a matrix''' | |
#Constructs matrix of same size as supplied matrix |
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
#The function f should return true iff is supplied the key you want to remove | |
def cloneExcluding(f, seq): | |
return filter(f, seq) |
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 sys | |
def sadify(string): | |
string = str(string) | |
out = "" | |
for char in string: | |
out += char.upper() + " " | |
return out+'B O Y S' | |
if(len(sys.argv)>=2): |
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
def balance(chars): | |
def testchar(chars, open, closed) | |
if (open < closed): | |
return False | |
if not chars: #chars is empty | |
return (open == closed) | |
if (chars.head == '('): | |
testchar(chars.tail, open+1, closed) | |
elif (chars.head == ')'): | |
testchar(chars.tail, open, closed+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
import argparse | |
import os | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-p",action="store_true",dest="playpause",default=False) | |
parser.add_argument("-n",action="store_true",dest="next",default=False) | |
parser.add_argument("-l",action="store_true",dest="previous",default=False) | |
results = parser.parse_args() |
NewerOlder