This file contains hidden or 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
| 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, ",") |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| defmodule MyList do | |
| def len([]), do: 0 | |
| def len([head|tail]), do: 1 + len(tail) | |
| end |
This file contains hidden or 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
| 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' |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 'use strict'; | |
| (function(global){ | |
| function isFunction(item) { | |
| return typeof item === 'function'; | |
| } | |
| function extend(target, options){ | |
| var copy; | |
| if(typeof target !== 'object' && !isFunction(target)){ | |
| target = {}; | |
| } |
NewerOlder