Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am adomokos on github.
  • I am adomokos ( on keybase.
  • I have a public key ASA8JcfM-KoBRcr5g7J-bADE-azTB3JtbjP0B6yn84UXygo

To claim this, I am signing this object:

adomokos / RomanNumeralsSpec.hs
Created Apr 26, 2017
The Roman Numerals kata in Haskell
View RomanNumeralsSpec.hs
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import qualified Data.Map as Map
import Data.List
mapping :: Map.Map Int String
mapping = Map.fromList [
(1, "I"),
(4, "IV"),
adomokos /
Created Apr 5, 2017
Type vs Data Constructors in Haskell

Type vs Data Constructors

In a data declaration, a type constructor is the thing on the left hand side of the equals sign. The data constructor(s) are the things on the right hand side of the equals sign. You use type constructors where a type is expected, and you use data constructors where a value is expected.

Data constructors

To make things simple, we can start with an example of a type that represents a colour.

data Colour = Red | Green | Blue
View string_calculator_test.go
package string_calculator
import (
func Convert(params ...string) int {
adomokos / string_calculator.hs
Created Jul 14, 2016
String Calculator in Haskell
View string_calculator.hs
module StringCalculator where
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Data.List.Split (splitOn)
calculator' :: String -> Char -> Integer
calculator' x c = sum $ coerceString x c
adomokos / Makefile
Last active Feb 18, 2020
Makefile template
View Makefile
THIS_FILE := $(lastword $(MAKEFILE_LIST))
build-db: ## Builds the DB
dropdb --if-exists --username $(DBUSER) $(DBNAME)
View change_maker.clj
(ns change-maker.core-test
(:require [clojure.test :refer :all]))
(def ^:dynamic *denominations* [25 10 5 1])
(defn best-match [value]
(first (filter #(<= % value) *denominations*)))
(defn calculate-change [value product]
(let [reducer (best-match value)]
adomokos / core_test.clj
Created May 15, 2015
Solving the Roman Numeral Kata in Clojure
View core_test.clj
(ns roman-numerals.core-test
(:require [clojure.test :refer :all]))
(def mapping {
0 ""
1 "I"
4 "IV"
5 "V"
9 "IX"
10 "X"
adomokos / string_calculator_spec.rb
Last active Aug 29, 2015
String Calculator Kata in Ruby - using enumerable methods
View string_calculator_spec.rb
# Solving the String Calculator Kata
class StringCalculator
def self.add(numbers)
return 0 if numbers.empty?
#splitted_array = numbers.split(",")
adomokos / group_by_spec.rb
Created Mar 5, 2014
Recognizing Ruby's group_by in the imperative code
View group_by_spec.rb
class Location
attr_reader :city, :user
def initialize(city, user)
@city = city
@user = user
class User
attr_reader :name