Created
October 28, 2012 12:10
-
-
Save ahoy-jon/3968456 to your computer and use it in GitHub Desktop.
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
import TypeConverter._ | |
import ParserCSV._ | |
import scalaz._ | |
import Scalaz._ | |
val csvReaderAhoy = readCSV("./csv/ahoy.txt") | |
case class Personne(nom:String, prenom:String, age:Option[Int]) | |
csvReaderAhoy(line => ^(line.nom.s,line.prenom.s,line.age.to[Option[Int]])(Personne)) //Iterator | |
csvReaderAhoy(line => ^(line.nom.s,line.prenom.s,line.age.to[Option[Int]])(Personne)).toList //List[ValidationNEL[String,Personne]] | |
csvReaderAhoy(line => line.nom.s) | |
csvReaderAhoy(line => line.nom.s).toList | |
csvReaderAhoy(line => line.age.to[Int]).toList | |
csvReaderAhoy(line => line.age.to[Option[Int]]).toList | |
csvReaderAhoy(line => line._3.to[Option[Int]]).toList | |
//Drop validation, keep only sucesses | |
val reader:ParserCSV.CSVParser = readCSV("./csv/ahoy.txt") | |
val lineIterator:Iterator[ValidationNEL[String,Personne]] = reader(line => {^(line.nom.s,line.prenom.s, | |
line.age.to[Option[Int]])(Personne)}) | |
val lPersonne: List[Personne] = lineIterator.toList.flatMap(_.toOption) | |
// lPersonne: List[Personne] = List(Personne(W,Jon,Some(25)), Personne(A,Alexis,None)) | |
//Some JS | |
~JS.Math.PI | |
~JS.Math.cos | |
~JS.Math.cos(JS.Math.PI) | |
~JS.Math.cos(0) | |
~JS.helloPSUG() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment