--------------------------------------------------------------------------------
================================================================================
================================================================================
If I was crying
In the van, with my friend
It was for freedom
From myself and from the land
================================================================================
--------------------------------------------------------------------------------
test
--------------------------------------------------------------------------------
Windows でいう win + D
Mac OS 10.5 だけかもしれない
--------------------------------------------------------------------------------
val r = (0 to 999)
((r by 3) ++ (r by 5)).distinct.sum // => 233168--------------------------------------------------------------------------------
import scala.collection.mutable
def isEven(n: BigInt): Boolean = (n % 2 == 0)
var fibs = mutable.Map[Int, BigInt]()
def fib(n: Int): BigInt = {
if (fibs.isDefinedAt(n)) return fibs(n)
if (n <= 2) return 1;
fibs(n) = fib(n - 1) + fib(n - 2)
return fibs(n)
}
var result = (1 to 28).map(n => fib(n)).reduceLeft { (a, b) => if (isEven(b)) println(a, b); if (isEven(b)) a + b else a + 0 }
println(result)
//(1,2)
//(3,8)
//(11,34)
//(45,144)
//(189,610)
//(799,2584)
//(3383,10946)
//(14329,46368)
//(60697,196418)
//257115
--------------------------------------------------------------------------------
def collatz(n: Int, list: List[Int] = Nil): List[Int] = n match {
case 1 => (n :: list).reverse
case n if n % 2 == 0 => collatz(n / 2, n :: list)
case _ => collatz(3 * n + 1, n :: list)
}
println(collatz(69)) // => List(69, 208, 104, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1)
--------------------------------------------------------------------------------
def collatz(n: Int) = n match {
case n if n % 2 == 0 => n / 2
case n => (3 * n) + 1
}
def nestWhileList[A](f: A => A, initial: A, p: A => Boolean) = {
val result = Stream.iterate(initial)(f).takeWhile(p).toList
result :+ f(result.last)
}
val cs = nestWhileList(collatz(_: Int), 200, (_: Int) != 1)--------------------------------------------------------------------------------
scala> "foo".
+ asInstanceOf charAt codePointAt codePointBefore codePointCount compareTo compareToIgnoreCase concat
contains contentEquals endsWith equalsIgnoreCase getBytes getChars indexOf intern isEmpty
isInstanceOf lastIndexOf length matches offsetByCodePoints regionMatches replace replaceAll replaceFirst
split startsWith subSequence substring toCharArray toLowerCase toString toUpperCase trim
“foo” で タブを押すと補完される
--------------------------------------------------------------------------------
"もうこの時点で「いやいやrequireは絶対パスで書くだろ、常識的に」とか「autoloadじゃないの?」とか「"
--------------------------------------------------------------------------------
<% assign var="url" value="http://`$rows.foo`.sample.com" %>--------------------------------------------------------------------------------
"「あなたへのおすすめ」じゃなくて「あなたが意地張ってフォローしない人たち」になってる"
--------------------------------------------------------------------------------
/_ah/admin/
--------------------------------------------------------------------------------
$ [ -d /var/log/hoge ] && echo 'HELLO'
$ [ ! -d /var/log/hoge ] && echo 'HELLO' # 否定--------------------------------------------------------------------------------
def deleteWord(replaceWords: String, originalWords: String) = {
val pattern = "[" + replaceWords + "]"
pattern.r.replaceAllIn(originalWords, " ").mkString
}
println(deleteWord("golf","flogwaiurhgm"))
--------------------------------------------------------------------------------
サイトの一部に http で通信しているものがあり、完全に暗号化できているわけではないというエラー。
--------------------------------------------------------------------------------
pg 1 of 40
================================================================================