Skip to content

Instantly share code, notes, and snippets.

@songpp
songpp / MyLinkedList.scala
Created February 23, 2013 16:32
反转双向链表。。。。。
package sun.flower.kata
/**
*
* User: sunflower
* Date: 13-2-23
* Time: 下午10:41
*
*/
object MyLinkedList {
@songpp
songpp / BinaryChop.scala
Created February 23, 2013 16:33
Kata 2
package sun.flower.kata
import annotation.tailrec
import java.util
/**
*
* User: sunflower
* Date: 13-2-23
* Time: 下午9:38
@songpp
songpp / P3.scala
Last active December 15, 2015 02:48
Project Euler Problem 3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
package sun.flower.euler
/**
*
* User: sunflower
* Date: 13-3-19
* Time: 上午12:54
*
* Problem 3:
* The prime factors of 13195 are 5, 7, 13 and 29.
@songpp
songpp / P4.scala
Last active December 15, 2015 02:49
http://projecteuler.net/problem=4 Largest palindrome product Problem 4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers.
package sun.flower.euler
/**
*
* User: sunflower
* Date: 13-3-19
* Time: 上午2:18
*
*/
/*
A palindromic number reads the same both ways.
@songpp
songpp / pom-cxf.xml
Created March 19, 2013 11:47
使用Maven的CXF插件自动生成JAVA类
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<defaultOptions>
// scala 2.7 simple type constraint. This can only constrain a type parameter of this function.
// Below, in ListW.sumint28, we can't use this approach because we want to constrain T,
// a type param of the enclosing trait.
def sumint27A[T <: Int](l: List[T]) : Int = l.reduceLeft((a: Int, b: Int) => a + b)
trait IntLike[X] extends (X => Int)
object IntLike {
implicit val intIntLike: IntLike[Int] = new IntLike[Int] { def apply(x: Int) = identity(x) }
}
@songpp
songpp / hslint
Created April 5, 2013 16:52 — forked from sritchie/hslint
#!/usr/bin/env perl
# Remember `chmod a+x hslint, after putting on path.
$ghc = '/usr/bin/ghc'; # where is ghc
@ghc_options = ('-Wall'); # e.g. ('-fglasgow-exts')
@ghc_packages = (); # e.g. ('QuickCheck')
### the following should not been edited ###
@songpp
songpp / error.log
Created April 7, 2013 09:03
rust 0.6 compile error
metaphor:include metaflower$ brew doctor
Your system is raring to brew.
metaphor:include metaflower$ brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: 56d86e070a60b9deac092a844993332945855027
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
@songpp
songpp / IterateeToy.scala
Last active December 15, 2015 22:09
count lines Iteratee toy http://okmij.org/ftp/Haskell/Iteratee/describe.pdf Oleg Kiselyov 论文里面的例子 Scala十分钟实现版
package sun.flower.iteratee
/**
*
* User: metaflower
* Date: 13-4-7
* Time: 下午11:02
*/
object IterateeToy {
@songpp
songpp / Iteratee.hs
Last active December 15, 2015 22:09
http://okmij.org/ftp/Haskell/Iteratee/describe.pdf Oleg Kiselyov 论文里面的例子
module ToyIteratee where
import Data.Maybe
import Control.Monad
-- Iteratee toy
type LC = Maybe Char