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
    
  
  
    
  | #include <iostream> | |
| #include <vector> | |
| // これはテストです | |
| int main() | |
| { | |
| std::vector<char*> v0; | |
| std::cout << "hello" << std::endl; | |
| return 0; | 
  
    
      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.Char | |
| import Prelude hiding (maximum, minimum, splitAt) | |
| -- ex 5.9 | |
| pyths :: Int -> [(Int,Int,Int)] | |
| pyths x | x <= 0 = [(0,0,0)] | |
| | otherwise = [(a,b,c) | a <- [1..x], | |
| b <- [a..x], | |
| c <- [b..x], | 
  
    
      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.Char | |
| -- homework 2.1 | |
| type Bit = Int | |
| bin2int :: [Bit] -> Int | |
| bin2int = foldr (\x y -> x + 2 * y) 0 | |
| int2bin :: Int -> [Bit] | 
  
    
      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 Prelude hiding (return, (>>=)) | |
| import Data.Char | |
| -- 8.2 | |
| type Parser a = String -> [(a, String)] | |
| -- 8.3 | |
| return :: a -> Parser a | 
  
    
      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
    
  
  
    
  | data Tree a = E | |
| | T (Tree a) a (Tree a) | |
| deriving (Show) | |
| empty :: Tree a -> Bool | |
| empty E = True | |
| empty (T _ _ _) = False | |
| insert :: Ord a => a -> Tree a -> Tree a | |
| insert x E = (T E x E) | 
  
    
      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
    
  
  
    
  | -- 10.5 | |
| data Expr = Val Int | Add Expr Expr | |
| value :: Expr -> Int | |
| value (Val n) = n | |
| value (Add x y) = value x + value y | |
| type Cont = [Op] | |
| data Op = EVAL Expr | ADD 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
    
  
  
    
  | import Maybe | |
| mwrap :: a -> Maybe a | |
| mwrap v = Just v | |
| mbind :: Maybe a -> (a -> Maybe b) -> Maybe b | |
| mbind Nothing _ = Nothing | |
| mbind (Just x) f = x | 
  
    
      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 Monad | |
| data Parser a = Parser (String -> [(a, String)]) | |
| pwrap :: a -> Parser a | |
| pwrap v = Parser $ \inp -> [(v, inp)] | |
| pbind :: Parser a -> (a -> Parser b) -> Parser b | |
| pbind (Parser p) f = Parser $ \inp -> case p inp of | |
| [] -> [] | 
  
    
      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
    
  
  
    
  | class Mappable m where | |
| (<$>) :: (a -> b) -> m a -> m b | |
| mmap :: (a -> b) -> Maybe a -> Maybe b | |
| mmap _ Nothing = Nothing | |
| mmap f (Just x) = Just $ f x | |
  
    
      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
    
  
  
    
  | data LeftistHeap a = E | T Int a (LeftistHeap a) (LeftistHeap a) | |
| deriving(Show) | |
| rank E = 0 | |
| rank (T r _ _ _) = r | |
| makeT x a b = if rank a >= rank b | |
| then T (rank b + 1) x a b | |
| else T (rank a + 1) x b a | 
OlderNewer