This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
digits n = | |
findDigits (rem n 10) [] (quot n 10) | |
where addDigit d ds = (abs d): ds | |
findDigits d ds 0 = addDigit d ds | |
findDigits d ds b = findDigits (rem b 10) (addDigit d ds) (quot b 10) | |
divisableDigits n = | |
length (filter divisable (digits n)) | |
where zero 0 = True | |
zero _ = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
require "ostruct" | |
BadContext = Class.new(OpenStruct) | |
class BetterContext | |
attr_accessor :a, :b, :c, :d, :e, :f | |
end | |
def test_it(klass, &b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defprotocol JsonApiClient.RequestPath do | |
@moduledoc """ | |
The `JsonApiClient.RequestPath` protocol provides a single function to be implemented that maps | |
a given Elixir term to a string representation of an url path. | |
""" | |
@doc """ | |
Converts `term` to a string representation of a given path. | |
""" | |
@spec to_path(term()) :: String.t |
OlderNewer