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
#!/usr/bin/env ruby | |
class Array | |
def transpose | |
width = self.map {|e| e.length}.max | |
trans = [] | |
(0..width - 1).each do |col| | |
self.each do |row| | |
element = row[col] | |
(trans[col] ||= []) << element |
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 TypeOperators #-} | |
import Prelude hiding ((.), id) | |
import Control.Arrow | |
import Control.Category | |
{- | |
> let math = ("add 2" :-: (+2)) . ("times 3" :-: (*3)) >>> ("invert" :-: (1/)) | |
> math | |
(invert) . ((add 2) . (times 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
import Closable | |
import ForkJoin | |
import Control.Concurrent | |
import System.Random | |
import Control.Monad | |
main = do | |
c <- newChan :: IO (Chan (Maybe String)) | |
forkIO $ getChanWhileJust c >>= mapM_ print |
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
{- | |
Plotting the dragon curve | |
========================= | |
Console Version | |
http://en.wikipedia.org/wiki/Lindenmayer_system | |
-} | |
import Control.Monad | |
import Control.Arrow |
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
{- | |
Plotting the dragon curve | |
========================= | |
Image Version | |
http://en.wikipedia.org/wiki/Lindenmayer_system | |
-} | |
import Control.Arrow | |
import Diagrams.AST hiding (X,Y) |
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
{- | |
Plotting the dragon curve | |
========================= | |
Console Version | |
http://en.wikipedia.org/wiki/Lindenmayer_system | |
-} | |
import System | |
import System.Random |
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 Diagrams.AST | |
import Control.Arrow | |
import Data.List | |
main = outputImage "Foo.png" 800 800 image | |
image = Images $ Atop spiral background | |
spiral = Modifier (Changes [Align C, Foreground red, LineWidth 0]) $ Shape $ Path Closed $ Offsets poly |
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 Diagrams.AST | |
import Control.Monad | |
main = forM_ [0..359] render | |
render i = outputImage ("image_" ++ show i ++ ".png") 100 100 $ animate (fromIntegral i) | |
animate t = Images $ Layers [ | |
Modifier (Align C) $ Images $ Layers [ | |
Modifier (Rotate $ Degrees t) shape |
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
#!/bin/bash | |
file="$1" | |
# Date flag | |
if [[ "$file" == "-v" ]] | |
then | |
file="$2" | |
verbose=1 | |
fi |
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 Data.Complex | |
import Codec.Image.DevIL | |
import Data.Array.Unboxed | |
import System.Directory | |
import Control.Monad | |
main = ilInit | |
>> doesFileExist path | |
>>= flip when (removeFile path) | |
>> writeImage path image |