{{ message }}

Instantly share code, notes, and snippets.

Created Apr 9, 2019
Keybase Proof
View keybase.md

Keybase proof

I hereby claim:

• I am adomokos on github.
• I am adomokos (https://keybase.io/adomokos) on keybase.
• I have a public key ASA8JcfM-KoBRcr5g7J-bADE-azTB3JtbjP0B6yn84UXygo

To claim this, I am signing this object:

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"),
Created Apr 5, 2017
Type vs Data Constructors in Haskell
View type_vs_data_constructors.md

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`
Created Jan 5, 2017
String Calculator in Go
View string_calculator_test.go
 package string_calculator import ( "github.com/stretchr/testify/assert" "strconv" "strings" "testing" ) func Convert(params ...string) int {
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
Last active Feb 18, 2020
Makefile template
View Makefile
 DBUSER=db_user DBPASSWD=db_password DBNAME=some_db THIS_FILE := \$(lastword \$(MAKEFILE_LIST)) .DEFAULT_GOAL := help build-db: ## Builds the DB dropdb --if-exists --username \$(DBUSER) \$(DBNAME)
Last active Jan 14, 2016
The Change Maker Kata - http://rubyquiz.com/quiz154.html
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)]
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"
Last active Aug 29, 2015
String Calculator Kata in Ruby - using enumerable methods
View string_calculator_spec.rb
 # Solving the String Calculator Kata # http://osherove.com/tdd-kata-1/ class StringCalculator def self.add(numbers) return 0 if numbers.empty? numbers.split(",").map(&:to_i).reduce(:+) #splitted_array = numbers.split(",")
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 end end class User attr_reader :name