Skip to content

Instantly share code, notes, and snippets.

import Control.Applicative
import Control.Monad
import Data.List
main = do
[m, n] <- map read . words <$> getLine
s <- forM [1..m] (\x -> getLine)
putStrLn $ show $ s !! n

test

# test2

main = putStrLn "helloworld"
module Main where
import Control.Applicative ((<$>))
import Control.Monad (forM)
type Pos = (Int, Int)
main :: IO ()
main = do
n <- read <$> getLine
@amutake
amutake / DeBruijn.hs
Last active December 18, 2015 22:59
An evaluator for De Bruijn Index
module DeBruijn where
import Data.List
data Expr = Var Int | App Expr Expr | Abs Expr deriving (Eq, Show)
subst :: Expr -> Int -> Expr -> Expr
subst (Var n) m e
| n == m = e
| otherwise = Var n
@amutake
amutake / gist:6929670
Created October 11, 2013 04:38
FizzBuzz in Erlang
-module(fizzbuzz).
-export([start/1]).
start(End) ->
Pid = self(),
FizzBuzz = spawn(fun() -> fizzbuzz(Pid, End) end),
Fizz = spawn(fun() -> fizz(3) end),
Buzz = spawn(fun() -> buzz(5) end),
FizzBuzz ! {Fizz, Buzz},
receive
@amutake
amutake / gist:7910653
Last active December 31, 2015 00:59
Anomaly: Not enough components to build the dependent tuple. Please report.
Inductive A : Set := a : A.
Definition fantom (n : nat) := A.
Definition fantom_succ {n : nat} : fantom n -> fantom (S n) :=
fun _ => a.
Inductive ty : forall n : nat, fantom n -> Prop :=
| zero : ty O a
| succ : forall (x : nat) (f : fantom x), ty x f -> ty (S x) (fantom_succ f).
{-# LANGUAGE FlexibleContexts
, TypeOperators
, DeriveDataTypeable
, ConstraintKinds
, FlexibleInstances
, MultiParamTypeClasses
, UndecidableInstances #-}
import Control.Eff
import Control.Eff.Exception
Require Import String List.
Import ListNotations.
Inductive Action : Type := action : string -> Action.
CoInductive Process : Type :=
| process : list (Action * Process) -> Process.
Inductive mu_derivative : Action -> Process -> Process -> Prop :=
| derivative_here : forall a q l, mu_derivative a (process ((a, q) :: l)) q
@amutake
amutake / RingBenchmarks.scala
Last active August 29, 2015 14:02
ring-benchmarks
package me.amutake
import akka.actor._
object RingBenchmarks {
sealed trait Msg
case class Start(n: Int, t: Int) extends Msg
case class Next(next: ActorRef) extends Msg
case object End extends Msg
@amutake
amutake / gist:5b1e575ae32d2e6286b2
Last active April 16, 2023 03:56
夏ゼミ順番
module Main where
import Control.Monad
import Data.Array.IO
import System.Random
type Name = String
-- 通常
participants :: [Name]