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 qsort (arr, left=0, right=arr.length-1, pl=left, pr=right) | |
x = arr[(left+right)/2] | |
begin | |
pl+=1 while arr[pl] < x | |
pr-=1 while arr[pr] > x | |
arr[pl], arr[pr] = arr[pr], arr[pl] | |
end while arr[pl] != arr[pr] | |
qsort(arr, left, pl-1) if pl-left > 1 | |
qsort(arr, pr+1, right) if right-pr > 1 | |
end |
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
-- Is List Literal with Number liar ? | |
-- | |
-- ;-) | |
-- | |
-- This Sample Code Depend on test-framework, and QuickCheck 2 | |
-- try this | |
-- cabal install test-framework | |
-- cabal install test-framework-th | |
-- cabal install test-framework-quickcheck2 | |
-- cabal install QuickCheck |
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
module Main ( main ) where | |
import Control.Applicative ( (<$>) ) | |
import qualified System.Console.ANSI as Console | |
import qualified Test.QuickCheck as QuickCheck | |
data ConsoleMode = Battle | Combo | Result deriving ( Eq, Show ) | |
main :: IO a | |
main = do |
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.Applicative hiding ( (<|>) ) | |
import Text.Parsec | |
-- parse like ruby's String.strip | |
escSpace parser = spaces *> parser <* spaces | |
-- parse like "between" in Text.Parsec | |
close opener parser closer = char opener *> escSpace parser <* char closer | |
-- Example |
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 Data.List ( isInfixOf ) | |
main = print . filter (isInfixOf "AAG") . sequence $ flip replicate "ACGT" 5 |
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
(define (loop-mod$ max) | |
(^x ((^v (if (= v (floor v)) (x->integer v) v)) | |
(cond ((<= max x) (fmod x max)) | |
((> 0 x) (fmod (+ x max) max)) | |
(else x))))) | |
(define (inner$ min max) (cut clamp min <> max)) | |
(define-class* <hsl> (<color>) | |
((hue :is-a <real> :filter (loop-mod$ 360)) |
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
nav#header-navigation > ul { | |
padding: 0.4em 0; | |
background-color: hsl(210, 30%, 60%); | |
background-image: | |
-webkit-linear-gradient( | |
hsl(210, 30%, 70%) | |
, hsl(210, 30%, 61%) 50% | |
, hsl(210, 30%, 59%) 50% | |
, hsl(210, 30%, 50%) | |
); |
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
# Interactive RGB Color Hex Convert | |
# usage: | |
# $ ruby rgb_to_hex.rb | |
# r g b > 255 51 234 | |
# hex: #ff33aa | |
# r g b > 0 | |
# ### Please type 3 int values: red green blue | |
# r g b > 132 256 -1 | |
# ### Please type 3 int values: (0 <= x <= 255) | |
# r g b > quit |
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
this is sample code | |
-- factorial. n! = 1 * 2 * 3 * ... * ( n - 1) | |
fact :: Int -> Int = F fact | |
-- Functor function for factorial | |
F f x :: (Int -> Int) -> Int -> Int = 1 if 0 `is` x else x * f $ x - 1 | |
-- Instead, functions define without Type Binding. | |
-- But, it maybe do unexpected work | |
fact2 = F2 fact2 -- fact2 :: Num a => a -> a |
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
-- dependency: utf8-string | |
data Character = Azu | Ruizu deriving Eq | |
instance Show Character where | |
show c = case c of | |
Azu -> "あず" | |
Ruizu -> "ルイズ" | |
class Mederable a where |