Skip to content

Instantly share code, notes, and snippets.

# coding:utf-8
def λ(a):
return a
def ほげ(a):
return a
print λ(5)
print ほげ(5)
<?php
function λ($a) {
return $a;
}
function ほげ($a) {
return $a;
}
echo λ(5);
def ほげ(n: Int): Int = {
n
}
println(ほげ(3))
type ほげ = Int
def α(n: ほげ): ほげ = {
n
type Birds = Int
type Pole = (Birds, Birds)
--
landLeft :: Birds -> Pole -> Pole
landLeft n (left, right) = (left + n, right)
landRight :: Birds -> Pole -> Pole
landRight n (left, right) = (left, right + n)
-- バランス棒
-- オレオレバインド(>>=)の実装
applyMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b
applyMaybe Nothing f = Nothing
applyMaybe (Just x) f = f x
main = do
print $ Just 3 `applyMaybe` \ x -> Just (x+1)
print $ Just "smile" `applyMaybe` \ x -> Just (x ++ " :)")
print $ Nothing `applyMaybe` \ x -> Just (x+1)
print $ Nothing `applyMaybe` \ x -> Just (x ++ " :)")
class A {
class B
def f(b: B) = println("Got my B!")
}
val a1 = new A
println(a1)
val a2 = new A
println(a2)
class A {
class B
def f(b: B) = println("Got my B!")
}
val a1 = new A
println(a1)
val a2 = new A
println(a2)
# -*- coding: utf-8 -*-
def AheGaoDoublePeace(text)
str = text
str = str.gsub(/(気持|きも)ちいい/,'ぎも゛ぢい゛い゛ぃ')
str = str.gsub(/(大好|だいす)き/,'らいしゅきいぃっ')
str = str.gsub(/(ミルク|みるく|牛乳)/,'ちんぽミルク')
str = str.gsub(/お(願|ねが)い/,'お願いぃぃぃっっっ゙')
str = str.gsub(/ぁ/,'ぁぁ゛ぁ゛')
str = str.gsub(/あ/,'ぁあああ あぉ')
function a() { return "hoge"; }
function b() { "use strict"; eeee; eeee }
(5 <= 6) ? console.log(a()) : console.log(b());
// (5 >= 6) ? console.log(a()) : console.log(b()); // エラー
function a() { return "hoge"; }
function b() { eeee; eeee }
(5 <= 6) ? console.log(a()) : console.log(b());
// (5 >= 6) ? console.log(a()) : console.log(b()); // エラー