Skip to content

Instantly share code, notes, and snippets.

@Nucleareal
Nucleareal / noifq.hs
Last active August 29, 2015 13:59
if文と三項演算子を使わずにaとbの大きい数を表示 - Haskell
main = do
let a = 10
b = 20 in
print $ if a > b then a else b
@Nucleareal
Nucleareal / lifegame.hsp
Created April 1, 2014 14:45
昔書かれた糞コード
#include "hspkey.as"
buffer 1 : picload ".\\img\\life.bmp"
lifesize_x = ginfo(12)/8
lifesize_y = ginfo(13)
gsel 0
betreg = 0 : betweencntr = 5
@Nucleareal
Nucleareal / mutableArgLengthFunc.hs
Created April 1, 2014 09:08
可変長引数のメモ
{-# LANGUAGE FlexibleInstances #-}
class Watashi a where
next :: [String] -> a
instance Watashi String where
next = unwords . reverse
instance (Watashi r) => Watashi (String -> r) where
next xs b = next $ b:xs
// 1. 使用言語・動作環境
// 言語 : C# 5.0
// コンパイラ: Microsoft (R) Visual C# Compiler version 12.0.21005.1
// IDE : Microsoft Visual Studio Express 2012 for Windows Desktop
// .Net : 4.5.50938
// OS : Windows 7 Professional
// 2. プログラムの特長・工夫した点等、アピールポイント
// LINQを使いました。
@Nucleareal
Nucleareal / problem
Last active August 29, 2015 13:57
どうぞ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC
{
class Program
{
@Nucleareal
Nucleareal / invfizzbuzz.hs
Created March 4, 2014 14:13
状況: 逆FizzBuzz問題を解いている 難題: qtmapの型不一致
data FizzBuzz = NumFB | Fizz | Buzz | FizzBuzz deriving (Eq, Show, Read)
invFizzBuzz :: [FizzBuzz] -> [(Int, Int)]
invFizzBuzz xs = fmap (\x ->
if izbz x xs then (x, qtmap x xs) else (-1, -1)
) [1..1000]
izbz :: Int -> [FizzBuzz] -> Bool
izbz x xs
@Nucleareal
Nucleareal / 99bottles.hs
Created March 4, 2014 12:52
99 Bottles of Beer on Haskell
import Control.Monad
show' :: Int -> String
show' x
| x == 0 = "no more bottles"
| x == 1 = "1 bottle"
| otherwise = show x ++ " bottles"
main = forM [99,98..0] (\x -> putStrLn $
@Nucleareal
Nucleareal / bbopK.hs
Last active August 29, 2015 13:56
不必要に長いbbop
import System.Random
import Control.Monad
bs :: String
bs = "firstspring1845"
bs' :: String
bs' = "fsrg84"
@Nucleareal
Nucleareal / bbop.hs
Created March 4, 2014 10:58
誰か手伝ってくれ~~~~~~~~
import System.Random
bbop :: RandomGen g => Int -> Int -> g -> String
bbop n c gen
= fmap (\x -> bbops !! x) $ take n $ randomRs (0, length bbops -1) gen where bbops = "ビビドレドオペレショ"
{- ビビッドレッド・オペレーション
0 1 2 3 4 5 6 7 8 9 1011121314
-}
import Control.Monad
main=forM[1..100](\x->putStrLn$
case(x`mod`3,x`mod`5)of
(0,0)->"FizzBuzz"
(0,_)->"Fizz"
(_,0)->"Buzz"
(_,_)->show x
)