Skip to content

Instantly share code, notes, and snippets.

View trknhr's full-sized avatar
🎈
Focusing

Teruo Kunihiro trknhr

🎈
Focusing
  • Nulab.inc
  • Fukuoka, Japan
View GitHub Profile
defmodule OpenBrace do
def regex(str) do
regex = ~r/\{.*\}/
match_strs = Regex.scan(regex, str)
remain_strs = Regex.split(regex, str)
ary = Enum.map(match_strs, fn(x) ->
match_str = to_string(x)
match_array = String.split(match_str, ",")
defmodule Caeser do
def caesar([], n), do: []
def caesar([head | tail], n) when head + n <= ?z, do: [head + n | caesar(tail, n)]
def caesar([head | tail], n), do: [head + n - (?z - ?a + 1) | caesar(tail, n)]
end
defmodule MyList do
def mapsum(array, func), do: Enum.reduce(array, 0, &(&2 + func.(&1)))
def max(array), do: Enum.reduce(array, nil, fn(v, arr) ->
case arr do
nil -> v
x when v <= x -> x
x when v > x -> v
end
defmodule MyList do
def len([]), do: 0
def len([head|tail]), do: 1 + len(tail)
end
tap 'caskroom/cask'
tap 'caskroom/versions'
tap 'homebrew/bundle'
tap 'homebrew/core'
tap 'homebrew/versions'
cask 'java'
brew 'ant'
brew 'autoconf'
brew 'openssl'
brew 'jpeg'
object FizzBuzz{
def main(args: Array[String])={
fizz_buzz(20)
}
def fizz_buzz(n: Int) = {
val threes = Stream.continually(List(None, None, Some("Fizz")).toStream).flatten
val fives = Stream.continually(List(None, None, None, None, Some("Buzz")).toStream).flatten
val hoge = threes.zip(fives).zip(from(1)).take(n).map{a =>
a._1 match{
case (None, None) => a._2
'use strict';
(function(global){
function isFunction(item) {
return typeof item === 'function';
}
function extend(target, options){
var copy;
if(typeof target !== 'object' && !isFunction(target)){
target = {};
}