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 Fib where | |
import qualified Data.Vector.Unboxed as V | |
import qualified Data.Vector.Fusion.Stream as S | |
import qualified Data.Vector.Fusion.Stream.Monadic as SM | |
import Data.Vector.Fusion.Stream.Size | |
import Data.Vector.Fusion.Util | |
{- | |
euler2 n = sum $ filter even $ takeWhile (<n) $ fibs | |
How can I write this and fuse into what's below? |
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
// The SLINK algorithm for Agglomerative Hierarchical Clustering in O(n^2) time and O(n) space. | |
public class SLINK { | |
public static final class SLINKClusteringResult { | |
public final int[] height; | |
public final int[] parent; | |
public SLINKClusteringResult(int[] height, int[] parent) { | |
this.height = height; | |
this.parent = parent; | |
} | |
} |
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 nightra.reversi.util | |
import scala.ref.WeakReference | |
import scalafx.beans.property.{Property, BooleanProperty, ObjectProperty} | |
import scalafx.beans.value.ObservableValue | |
import scalafx.collections.ObservableBuffer | |
import scalafx.event.subscriptions.Subscription | |
object JavaFXUtil { | |
/** |
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
Functional Programming is based on the concept of using pure functions, | |
which at first sight limit us from various things as I/O, mutation - change and throwing exceptions - dealing with errors or uncertainty. | |
Optics help us deal with change inside compound structures and with branches (as with error handling), | |
by providing facilities for looking into complex structures, and modifying a part of them, | |
as well as powerful abstractions for composing optics, in order to build even more complex systems. | |
In this talk, I will introduce some of the optics, as Lenses, Prisms and Isomorphisms, and the motivation behind them, | |
powerful use cases with Polymorphic Optics in Monocle, | |
and explain the deep and interesting representation of Lenses through Van Laarhoven Lenses, |
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
מה עשית? | |
[21:35:30] Ilan: ואו, הרבה | |
[21:35:36] Ilan: היו תחנות | |
[21:35:41] Ilan: תחנה 1: | |
[21:36:00] Ilan: סימולציה שאתה עובד כלשהו ויש לקוח לא מרוצה | |
[21:36:48] Ilan: אני הייתי מוכר הכרטיסים בקולנוע ובאה אחת שהזמינה 2 כרטיסים בשורה 10 ונתנו לה כרטיס בשורה 1 ובשורה 5 | |
[21:36:52 | 21:36:54 נערך] Ilan: והיא רוצה לשבת עם חברה שלה | |
[21:37:01] Ilan: ואי אפשר לתת החזר כספי | |
[21:37:23] Ilan: ואי אפשר יום אחר כי זה היום הולדת של חברה שלה | |
[21:37:50] Ilan: וניסיתי לעזור לה שאולי תשאל אנשים באולם אם אפשר להחליף |
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
Wanted behavior: | |
[info] Started 1 | |
[info] Started 2 | |
[info] Started 3 | |
[info] Started 4 | |
[info] Started 5 | |
[info] Finished 5 in 215 | |
[info] Finished 4 in 615 | |
[info] Finished 3 in 825 | |
[info] Finished 2 in 1109 |
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 nightra.mashovNotificator.network | |
import scala.concurrent.{ExecutionContext, Future} | |
import scalaz.effect.IO | |
import scalaz.effect.IO._ | |
import scalaz.Reader | |
import scala.util.{Success, Failure, Try} | |
case class Task[A](task: Reader[ExecutionContext, IO[Future[A]]]) { | |
def map[B](f: A => B): Task[B] = Task(Reader(implicit executor => task(executor).map(_.map(f)))) |
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
Pre-Oreder: | |
root-->left-->right | |
In-Oreder: | |
left-->root-->right | |
Post-Oreder: | |
left-->right-->root | |
================================================== | |
Sorts: | |
Max-Sort: |
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 Decorable[A, B] { | |
def decorate(obj: A, dec: B): Either[String, A] | |
} | |
object Decorator { | |
def decorate[A, B](implicit d: Decorable[A,B]) = d | |
} | |
object TagsDecorator { |
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 Functor { | |
type M <: { type T } | |
def fmap[A, B](fa: M { type T = A })(f: A => B): M { type T = B } | |
} | |
implicit class EitherRightFunctor extends Functor { self => | |
type L | |
type M = Either { type A = self.L ; type T = B } //doesn't this specify a subtype of Either, rather than Either itself? | |
def fmap[A0, B0](fa: M { type A = self.L ; type B = A0 })(f: A0 => B0): Either { type A = self.L ; type B = B0 } = |
NewerOlder