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 Sort ( | |
bubbleSort, | |
mergeSort, | |
quickSort) where | |
import Data.List (splitAt) | |
bubbleSort, mergeSort, quickSort :: Ord a => [a] -> [a] | |
bubbleSort xs = foldr ((.) bubbleSort' . flip const) xs [0..length xs] |
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 "openurl.h" | |
#ifdef _WIN32 | |
#include <windows.h> | |
#else | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
#endif |
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
-- 存在量子化されたデータ構築子が使えるみたいです>ω<←よく分かってないヾ(゚Д゚ )ォィォィ | |
{-# LANGUAGE ExistentialQuantification #-} | |
module Main where | |
import Prelude hiding (head) | |
data Empty | |
data NoEmpty | |
data StrongList a x = forall y. Cons a (StrongList a y) | |
|Nil |
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
-- Generalized Algebraic Data Types(一般的代数データ型)が使えるようになるみたいです>ω< | |
{-# LANGUAGE GADTs #-} | |
module Main where | |
import Prelude hiding (head) | |
-- Phantom Typeではラッパー関数が必要でしたけれど、 | |
-- GADTではデータ構築子の返す型を別々にできるみたいですー>ω< | |
-- シンプルで堅牢で、とても素敵ですっ>ω< | |
data Empty | |
data NonEmpty |
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 GSort (bubbleSort) where | |
import Prelude hiding (head, tail, foldr, foldr1) | |
import Control.Monad | |
import Data.Foldable | |
bubbleSort' :: (Ord a, MonadPlus m, Foldable m, Eq (m a)) => m a -> m a | |
bubbleSort' xs | |
|xs == mzero = xs | |
|xs' == mzero = return x |
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
(defn fizzbuzz [n] (let [fizz (zero? (mod n 3)) | |
buzz (zero? (mod n 5))] (cond | |
(and fizz buzz) 'FizzBuzz | |
fizz 'Fizz | |
buzz 'Buzz | |
:else (str n)))) | |
(println (clojure.string/join "\n" (map fizzbuzz (range 1 101)))) |
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
(defn fib [x y] (cons x (lazy-seq (fib y (+ x y))))) | |
(print (take 20 (fib 1 1))) |
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
package com.github.kagamilove0707.safelist; | |
public interface Callback<A> { | |
public void call(A val); | |
} |
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
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-} | |
module ShiritoriTH where | |
import Data.Char | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Quote | |
letterDec :: (Char, Char) -> Q [Dec] | |
letterDec (from, to) = (mapM (\c -> let | |
n = mkName $ "Letter" ++ return c | |
in return $ [DataD [] n [] [NormalC 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
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Data.Pair (Pair, pair, (<:>)) where | |
import Data.Monoid | |
import Control.Applicative | |
newtype Pair a = Pair (a, a) deriving (Show, Eq, Monoid) | |
infixl 5 <:> | |
pair, (<:>) :: a -> a -> Pair a |
OlderNewer