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 DependentTypedLength extends App { | |
| sealed trait Nat | |
| sealed trait Z extends Nat | |
| sealed trait S[A <: Nat] extends Nat | |
| trait NList[A <: Nat, +B] { |
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
| import scala.annotation.tailrec | |
| object NewtonRaphsonSquareRoot extends App { | |
| @tailrec | |
| def within(epsilon: Double, s: Stream[Double]): Double = s match { | |
| case x0 #:: x1 #:: xs => if (math.abs(x0 - x1) < epsilon) x1 else within(epsilon, x1 #:: xs) | |
| } | |
| def sqrt(n: Double)(implicit epsilon: Double): Double = { |
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
| module NewtonRaphson.Sqrt (nrSqrt) where | |
| nrSqrt :: Double -> Double | |
| nrSqrt n = within 0.001 (approximations init n) | |
| where init = n / 2 | |
| approximations :: Double -> Double -> [Double] | |
| approximations x0 n = iterate (next n) x0 | |
| next :: Double -> Double -> Double |
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
| trait A { type T <: A } | |
| trait B { type T <: B } | |
| trait C extends A with B { type T <: C } | |
| trait D extends A with B { type T <: D } | |
| val o: A with B { | |
| type T <: A with B { | |
| type T <: A with B { | |
| type T <: A with B { | |
| type T <: A with B { |
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
| package org.kornel.collatz | |
| object CollatzScala extends App { | |
| import StreamTakeWhileInclusive.StreamTWI | |
| val start = 15 | |
| val collatz = Stream.iterate(15) { | |
| case n if n % 2 == 0 => n / 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
| module Collatz where | |
| collatz :: (Integral a) => a -> [a] | |
| collatz a = takeWhileIncl (/= 1) $ collatzSeq a | |
| nextCollatz :: (Integral a) => a -> a | |
| nextCollatz n = if (even n) then n `div` 2 else (3 * n + 1) | |
| collatzSeq :: (Integral a) => a -> [a] | |
| collatzSeq = iterate nextCollatz |
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
| name := "flink-start" | |
| version := "1.0" | |
| scalaVersion := "2.11.6" | |
| libraryDependencies ++= | |
| Seq("org.apache.flink" % "flink-clients" % "0.8.1", | |
| "org.apache.flink" % "flink-scala" % "0.8.1") |
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
| #!/bin/bash | |
| MAHOUT_HOME=$PWD/mahout-mahout-0.11.0 | |
| #export MAHOUT_LOCAL=$PWD/mahout-mahout-0.11.0 | |
| SPARK_HOME=/usr/lib/spark1.5/ | |
| INPUT=/projects/reco_prod/data/sessions-cf/second/ | |
| OUTPUT=/projects/reco_prod/data/sessions-cf/similarity | |
| EXECUTOR_MEM=14g |
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
| #!/bin/sh | |
| SSHELL=~/spark-1.5.0-bin-2.5.0-cdh5.3.1/bin/spark-shell | |
| #SSHELL=~/spark-1.4.0-bin-2.5.0-cdh5.3.1/bin/spark-shell | |
| #SSHELL=spark-shell | |
| SSHELL=spark-shell1.5 | |
| JAR=./lib/reco-analyzer-assembly-1.12.1-SNAPSHOT.jar | |
| #SPARK_HOME=~/spark-1.5.0-bin-2.5.0-cdh5.3.1 $SSHELL --master yarn --driver-memory 3g --jars $JAR --queue reco_prod --num-executors 20 --driver-java-options "-Dspark.executor.memory=4g" |
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
| package com.allegrogroup.reco.analyzer.spark.session | |
| import org.apache.spark.SparkContext | |
| import org.apache.spark.rdd.RDD | |
| class SessionsSimilarity { | |
| case class SessionEvent(sessionId: String, itemId: String) | |
| def run(sc: SparkContext) { |
OlderNewer