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
#!/usr/bin/env runghc | |
import Control.Monad | |
import Data.Function | |
import Data.Functor | |
import Data.List | |
import System.Directory | |
import System.FilePath | |
data ELPA = ELPA FilePath |
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
bi :: (a -> b) -> (a -> c) -> a -> (b, c) | |
bi f g (x) = (f x, g x) | |
bi2 :: (a -> b -> c) -> (a -> b -> d) -> (a, b) -> (c, d) | |
bi2 f g (x, y) = (f x y, g x y) | |
tri :: (a -> b) -> (a -> c) -> (a -> d) -> a -> (b, c, d) | |
tri f g h (x) = (f x, g x, h x) | |
tri2 :: (a -> b -> c) -> (a -> b -> d) -> (a -> b -> e) -> (a, b) -> (c, d, e) |
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
[1] |> Stream.iterate(fn(x) -> x |> Enum.chunk_by(&+/1) |> Enum.flat_map(fn([x|_]=c) -> [x, Enum.count(c)] end) end) |> Enum.take(10) |
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
natural-sort [ zero? ] partition dup length 2 < [ 2drop -1 ] [ 2 cut swapd 3append zip-index [ second even? ] partition [ keys 0 [ swap 10 * + ] reduce ] bi@ + ] if | |
natural-sort [ zero? ] partition dup length 2 < [ 2drop -1 ] [ 2 cut surround zip-index [ second even? ] partition [ keys 0 [ swap 10 * + ] reduce ] bi@ + ] if |
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
: >column-name ( n -- s ) "" [ over zero? ] [ [ 1 - 26 /mod 65 + ] dip swap prefix ] until nip ; |
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
dup 1 tail zip [ [ second ] [ first ] bi - ] sort-with first |
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 unittest | |
def has_branches(tree): | |
return len(tree) >= 1 | |
def depth(tree): | |
if has_branches(tree): | |
return 1 + max(map(depth, tree)) | |
else: | |
return 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 unittest | |
def has_branch(tree): | |
return False | |
class DepthTest(unittest.TestCase): | |
#I guess, testing existence of branches might be useful to calculate the depth of tree. | |
def test_has_branch(self): | |
tree = [] | |
self.assertFalse(has_branch(tree)) |
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 unittest | |
def depth(tree): | |
return 1 | |
class DepthTest(unittest.TestCase): | |
#Simplest tree is a tree which has just one node with no branches. In that case, the depth is 1. | |
def test_no_children(self): | |
tree = [] | |
self.assertEquals(1, depth(tree)) |
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
첫째날 | |
10:00 소개 | |
10:10 실습 | |
10:30 휴식 | |
0h 40m |
OlderNewer