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
# modified from this: | |
# https://github.com/iaciac/py-draw-simplicial-complex/blob/master/Draw%202d%20simplicial%20complex.ipynb | |
from copy import copy | |
import networkx as nx | |
import itertools | |
import matplotlib.pyplot as plt | |
import numpy as np |
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
amount line = read (splitOn "from" ((splitOn "move" line)!!1)!!0) :: Int | |
src line = read (splitOn "to" ((splitOn "from" line)!!1)!!0) :: Int | |
dst line = read (splitOn "to" ((splitOn "from" line)!!1)!!1) :: Int |
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
-- sexpr parsing in Haskell | |
import Data.SCargot | |
import Data.SCargot.Language.Basic | |
import Data.Text | |
main = do | |
print (decode basicParser (pack "(- (+ 1 2) 3)")) |
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
sum_list [] = 0 | |
sum_list (elt:elts) = (read elt :: Integer) + sum_list elts |
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
main = do | |
content <- readFile "input.txt" | |
mapM_ putStrLn (lines content) |
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
-- Factorial recursively defined in Haskell | |
fac n = if n == 0 then 1 else n * fac (n-1) | |
main = print (fac 5) |
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
# Hindley-Milner type inference in Pyret | |
# needs fixing, Pyret's syntax has changed substantially since 2013 | |
# this was written in a functional language. | |
# can I take this and turn it into Haskell? | |
#lang pyret/whalesong | |
data Expr: | |
| idE(name :: String) |
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
import time | |
fout = open("test_1.txt", "w") | |
i = 0 | |
while True: | |
fout.write(f"heartbeat {i}\n") | |
fout.flush() | |
i += 1 | |
time.sleep(1) |
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
# I wrote this sometime in 2007 or 2008 so please be forgiving | |
# of younger me and his terrible code | |
from vpython import * | |
from time import sleep | |
from copy import deepcopy | |
class Heat2D: | |
def __init__(self, inittemp, k, max = 255): | |
self.prevtemp = deepcopy(inittemp) | |
self.k = k |
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
# modified from this: | |
# https://github.com/iaciac/py-draw-simplicial-complex/blob/master/Draw%202d%20simplicial%20complex.ipynb | |
from copy import copy | |
import networkx as nx | |
import itertools | |
import matplotlib.pyplot as plt | |
import numpy as np |