Skip to content

Instantly share code, notes, and snippets.

View TakashiHarada's full-sized avatar

HARADA Takashi TakashiHarada

  • Kochi University of Technology
  • Kami City, Kochi, Japan
View GitHub Profile
#include "list.h"
#include <math.h>
struct MATRIX {
unsigned m;
unsigned n;
char** b;
};
typedef struct MATRIX matrix;
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]]
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 ->
module BNF2Props where
import Parser
import Control.Applicative
import Data.Char
import Data.Maybe
--import Text.Parsec.String.Parsec (parse)
{-
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
-- 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 >>=
module ex7-1-1 where
data Bool : Set where
t : Bool
f : Bool
not : Bool → Bool
not t = f
not f = t
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
#include <stdio.h>
#include <stdlib.h>
int P(int);
int main()
{
int n;
scanf("%d",&n);
printf("p(%d) = %d\n", n, P(n));
import Control.Monad
import Control.Applicative
import Data.Array.IO
import Data.Char
-- http://d.hatena.ne.jp/eiel/20120217
{-
3 4 4
1101