This file contains 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
//============================================================================ | |
// Name : Algorithm.cpp | |
// Author : Songpp | |
// Description : Hello World in C++, Ansi-style | |
//============================================================================ | |
#include <iostream> | |
#include <vector> | |
using namespace std; |
This file contains 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
package par | |
import scala.util.parsing.combinator._ | |
class SqlTokenParser extends JavaTokenParsers{ | |
def ws : Parser[String] = """\s+""".r | |
def query : Parser[Any] = selectClouse ~ fromClouse |
This file contains 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
-- fold left | |
foldLeft :: (b -> a -> b) -> b -> [a] -> b | |
foldLeft _ acc [] = acc | |
foldLeft f acc (x : xs) = foldLeft f (f acc x) xs | |
-- fold right | |
foldRight :: (a -> b -> b) -> b -> [a] -> b | |
foldRight f acc [] = acc | |
foldRight f acc (x : xs) = f x (foldRight f acc xs) |
This file contains 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
module Tree where | |
data Tree v = EmptyTree | |
| Node v (Tree v) (Tree v) | |
deriving Show | |
singleton value = Node value EmptyTree EmptyTree | |
--map f EmptyTree = EmptyTree | |
--map f Node v left right = Node (f v) (map f left) (map f right) |
This file contains 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
window.onerror = function() { | |
/** | |
* onerror 事件 | |
* arguments 共三个 | |
* | |
* 第一个 错误原因 | |
* 第二个 所在js文件 | |
* 第三个 第几行 | |
*/ | |
arglen = arguments.length; |
This file contains 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
def t1(ar1,ar2,&block) | |
if(block_given?) | |
yield(ar1,ar2) | |
else | |
puts ar1 , ar2 | |
end | |
block.call(ar1,ar2) | |
end | |
This file contains 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
package flower.april.sort | |
import flower.april.util.ArrayUtils | |
/** | |
* Date: 2010-7-26 | |
* Time: 12:34:40 | |
* Description: | |
*/ |
This file contains 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
package flower.april.continuation | |
import scala.util.continuations._ | |
import java.util.{Timer, TimerTask} | |
/** | |
* User: i-flower | |
* Date: 2010-8-10 | |
* Time: 20:28:05 | |
* this blow up my mind |
This file contains 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
package org.songpp.structure | |
object AVLTree { | |
/** | |
* 2011-04-03 | |
* 未完成。 | |
* 关键的旋转算法还没实现。 | |
* toy-writing for fun and studying scala | |
* base on scala collections framework |
This file contains 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
package org.songpp.fp | |
/* | |
* scala | |
*/ | |
trait FoldLeft[F[_]] { | |
def foldLeft[A, B](xs: F[A], init: B, func: (B, A) => B): B | |
} | |
object FoldLeft { | |
implicit object FoldLeftList extends FoldLeft[List] { |