Skip to content

Instantly share code, notes, and snippets.

View CarloMicieli's full-sized avatar
🦀
rust

Carlo Micieli CarloMicieli

🦀
rust
View GitHub Profile
package foo
import scala.language.higherKinds
trait Semigroup[M] extends Any {
def mAppend(x: M, y: M): M
}
trait Monoid[M] extends Semigroup[M] {
def zero: M
package foo
sealed trait ParsingError extends Any {
def error: String
override def toString: String = s"Parsing error: $error"
}
case object NoInputError extends ParsingError {
override def error: String = "No more input"
}
final case class WrongMatch[A](expected: A, found: A) extends ParsingError {
@CarloMicieli
CarloMicieli / AkkaFibonacci.scala
Created March 29, 2016 19:10
Fibonacci numbers with Akka
package io.github.carlomicieli.fibonacci
import java.util.concurrent.atomic.AtomicInteger
import akka.actor._
import akka.event.LoggingReceive
import scala.io.StdIn
object FibonacciApp1 {
module HsList ( List(..)
, fromList
, (+++)
, singleton
, map
, length
, intersperse
, intercalate
, concat
, and
@CarloMicieli
CarloMicieli / p99.lhs
Last active August 29, 2015 14:14
99 haskell problems
Ninety-Nine Haskell Problems
============================
[Original page](https://www.haskell.org/haskellwiki/H-99:_Ninety-Nine_Haskell_Problems)
> import Data.List
Lists
-----
twoLargest :: (Num a, Ord a) => a -> a -> a -> (a, a)
twoLargest x y z
| x <= y && x <= z = (y, z)
| y <= x && y <= z = (x, z)
| otherwise = (x, y)
square :: (Num a) => a -> a
square x = x * x
squarePair :: (Num a) => (a, a) -> (a, a)
@CarloMicieli
CarloMicieli / install-ubuntu.sh
Last active May 6, 2017 08:11
Installation script for Ubuntu 16.04
#!/bin/bash
## Constants
NONE='\e[39m'
RED='\e[31m'
GREEN='\e[32m'
CYAN='\e[36m'
### ======================================================================= ###
### HELPER FUNCTIONS ###
public class ReferenceSamples {
public static void main(String[] args) {
references();
equality();
}
private static void equality() {
Integer i1 = 1;
int i2 = i1;
assert i1 == i2 && i1.equals(i2);