Skip to content

Instantly share code, notes, and snippets.

View righ1113's full-sized avatar
🏠
Working from home

righ1113

🏠
Working from home
View GitHub Profile
@righ1113
righ1113 / Godel07.idr
Last active July 5, 2023 19:58
ゲーデルの不完全性定理 in Idris
module Godel07
%default total
%hide Functor
-- 証明をYesコンストラクタでくるんで、Proofable型にする
data Proofable : Type -> Type where
Yes : (prf : prop) -> Proofable prop
@righ1113
righ1113 / ArrowExample.hs
Last active April 23, 2020 08:50
アローの例題
{-
参考記事:
https://qiita.com/Lugendre/items/6b4a8c8a9c85fcdcb292
https://qiita.com/waddlaw/items/49874f4cf9b680e4b015
-}
{-# LANGUAGE Arrows #-}
module ArrowExample where
import Prelude hiding (id, (.))
import Control.Category (Category(..))
@righ1113
righ1113 / BreakLoop.hs
Last active June 14, 2019 23:54
foldl, foldrを元にした、蓄積変数付き、脱出可能なloop関数
-- 参考記事:https://mkotha.hatenadiary.org/entry/20110430/1304122048
module BreakLoop where
import Prelude hiding (take)
myLoop :: (accT -> a -> (accT -> b) -> b) -> (accT -> b) -> accT -> [a] -> b
myLoop _ g acc [] = g acc
myLoop f g acc (x:xs) = f acc x $ \acc' -> myLoop f g acc' xs
@righ1113
righ1113 / Ramsey05.idr
Last active July 5, 2023 19:56
ラムゼーの有名なやつ in Idris, Egison
-- module Ramsey05
module Main
%default total
comb : Nat -> List a -> List (List a)
comb Z _ = [[]]
comb (S n) [] = []
comb (S n) (x :: xs) = [x :: y | y <- comb n xs] ++ comb (S n) xs
@righ1113
righ1113 / EightPuzzle.hs
Last active July 5, 2023 19:58
8パズルは181440通り in Egison, Haskell
module EightPuzzle where
import Data.List (permutations)
-- 参考記事:https://mathtrain.jp/8puzzle
{--
8 puzzle
1 2 3
@righ1113
righ1113 / MagicSquare.hs
Last active September 26, 2019 14:38
3*3魔方陣は1種類しか存在しない
module MagicSquare where
import Data.List (permutations)
{--
3*3 Magic square
a b c
d e f
@righ1113
righ1113 / zdk.egi
Last active November 17, 2023 01:47
『ズンドコキヨシ with パターンマッチ指向言語Egison』をnew syntaxで
--
-- zundoko kiyoshi
--
-- $ egison 4.1.3
-- > loadFile "zdk.egi"
-- > zdk
--
-- Codes
@righ1113
righ1113 / CosineFormula.idr
Last active July 5, 2023 19:59
ベクトルを用いた余弦定理の証明 in Idris, Lean
module CosineFormula
-- > idris -p base
import Syntax.PreorderReasoning
%default total
%hide Language.Reflection.P
%hide cos
@righ1113
righ1113 / MultiOf3.idr
Last active July 5, 2023 19:59
各桁の和が3の倍数な整数は3の倍数 in Idris
module MultiOf3
%default total
-- isMm3 y x : -3y + x
data Mm3 : (y : Nat) -> Type where
isMm3 : (y : Nat) -> Nat -> Mm3 y
-- 3の倍数か判定する
@righ1113
righ1113 / multiOf3.lean
Last active July 5, 2023 19:59
各桁の和が3の倍数なら、元の数も3の倍数 in Lean
open nat
#check succ
-- isMm3 y x : -3y + x
inductive Mm3 (y : ℕ)
| isMm3 : ℕ → Mm3
open Mm3
#check isMm3 3 5