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
#include "list.h" | |
#include <math.h> | |
struct MATRIX { | |
unsigned m; | |
unsigned n; | |
char** b; | |
}; | |
typedef struct MATRIX matrix; |
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
fact :: Integer -> Integer | |
fact n = product [1..n] | |
comb :: Integer -> Integer -> Integer | |
comb n k = product [(n-k+1)..n] `div` (fact k) | |
f :: Integer -> Integer | |
f w = sum [(comb (3^w) k) * (fact k) * 2^k | k <- [1..3^w]] |
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 Parser | |
import BNF2Props | |
import System.IO | |
import System.Environment | |
import Data.Maybe | |
import Data.List | |
main = | |
putStr "Input a grammar file: " >> -- grammar.txt | |
getLine >>= \filename -> |
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 BNF2Props where | |
import Parser | |
import Control.Applicative | |
import Data.Char | |
import Data.Maybe | |
--import Text.Parsec.String.Parsec (parse) | |
{- |
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 Parser where | |
-- for Text.Parsec | |
-- https://github.com/JakeWheat/intro_to_parsing/blob/master/FunctionsAndTypesForParsing.lhs | |
-- I refered to the "Programming in Haskell 2nd edition" for implemeting this module. | |
import Control.Applicative | |
import Data.Char | |
import Data.List |
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
-- https://en.wikibooks.org/wiki/Haskell/Monad_transformers | |
import Data.Char | |
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.Trans.Maybe | |
-- getPassphrase :: IO (Maybe String) | |
-- getPassphrase = | |
-- getLine >>= |
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 ex7-1-1 where | |
data Bool : Set where | |
t : Bool | |
f : Bool | |
not : Bool → Bool | |
not t = f | |
not f = t |
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 hiding (find) | |
data Prop = | |
Const Bool -- 恒真命題(T),恒偽命題(⊥) | |
| Var Char -- 論理変数( p, q, r, ...) | |
| Not Prop -- ¬ x | |
| And Prop Prop -- x ∧ y | |
| Or Prop Prop -- x ∨ y | |
| Xor Prop Prop -- x ⊕ y | |
| NotBut Prop Prop -- x < y |
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
#include <stdio.h> | |
#include <stdlib.h> | |
int P(int); | |
int main() | |
{ | |
int n; | |
scanf("%d",&n); | |
printf("p(%d) = %d\n", n, P(n)); |
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.Monad | |
import Control.Applicative | |
import Data.Array.IO | |
import Data.Char | |
-- http://d.hatena.ne.jp/eiel/20120217 | |
{- | |
3 4 4 | |
1101 |