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:
I hereby claim:
To claim this, I am signing this object:
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"), |
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.
To make things simple, we can start with an example of a type that represents a colour.
data Colour = Red | Green | Blue
package string_calculator | |
import ( | |
"github.com/stretchr/testify/assert" | |
"strconv" | |
"strings" | |
"testing" | |
) | |
func Convert(params ...string) int { |
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 |
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) |
(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)] |
(ns roman-numerals.core-test | |
(:require [clojure.test :refer :all])) | |
(def mapping { | |
0 "" | |
1 "I" | |
4 "IV" | |
5 "V" | |
9 "IX" | |
10 "X" |
# 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(",") |
class Location | |
attr_reader :city, :user | |
def initialize(city, user) | |
@city = city | |
@user = user | |
end | |
end | |
class User | |
attr_reader :name |