Skip to content

Instantly share code, notes, and snippets.

sealed trait Command
case object Bid extends Command
case object Quit extends Command
case object Unrecognized extends Command
sealed trait Result
case object Won extends Result
case object Lost extends Result
// result is never used, can this line be removed?
val result = calculate(input)
update(input)
save(input.child)
foo()
// can the above four lines be re-arranged in a different order?
@bkyrlach
bkyrlach / problem09.scala
Last active August 29, 2015 14:02 — forked from DeepSky8/problem09.scala
Code review for Joel...
//In order to use the type paramter A, you must define it right after the method name.
//Something like...
//def pack[A](...)
def pack(input: List[A]): List[List[A]] = {
//This seems to be a perfect case for pattern matching? Why not use...
// input match {
// case Nil => Nil
// case h :: t => ...
// }
if(input == Nil) {
@bkyrlach
bkyrlach / M1.scala
Last active August 29, 2015 14:13 — forked from anonymous/M1.scala
//module M1
object M1 {
//Next two imports are like importing Parsec
import scala.util.parsing.combinator.{Parsers,RegexParsers}
import scala.util.parsing.input._
//Scalas version requires a bit more noise
object LispParser extends Parsers {
//Have to tell it that we want to parse characters
@bkyrlach
bkyrlach / Program.scala
Created October 16, 2015 19:03 — forked from dvanwinkle/memo.swift
Memoization in Swift
object Program {
def main(args: Array[String]): Unit = {
var fib: BigInt => BigInt = null
fib = n => {
n match {
case x if x <= 2 => 1
case x => fib(x - 1) + fib(x - 2)
}
@bkyrlach
bkyrlach / QueueStack.cs
Created March 2, 2016 19:32 — forked from DeepSky8/QueueStack.cs
Learning about Stacks and Queues, simultaneously. Please forgive the way that I call this a Stack, and then use all Queue terms for the methods.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Stack
{
class Program
{
@bkyrlach
bkyrlach / stuff.cs
Last active April 6, 2016 19:46 — forked from ckimball/gist:9e4a9932970d0d584dcb713b38a2a057
Notification Processing Rewrite
/// <summary>
/// Attempt to process the RabbitMQ message for the subscriber notification
/// </summary>
/// <param name="message"></param>
/// <param name="retryCount"></param>
/// <returns></returns>
private IoEither<Failure, Unit> ProcessMessage(IConsumeContext<ProcessSubscriberNotification> message, int retryCount)
{
Func<IConsumeContext<ProcessSubscriberNotification>, string, int, IoEither<Failure, Unit>> delayMessageProcessing = (m, log, delay) =>
from _0 in Logger.DebugU($"STI Subscriber Notification Handler: {log}. Will retry after a delay of {delay} milliseconds.").ToIoEither<Failure, Unit>()