module Nuggets::Integer::MapMixin

Public Instance Methods

map_positive → anInteger click to toggle source

Creates a bijection from Z to N, i.e., it maps int to a positive integer.

   # File lib/nuggets/integer/map_mixin.rb
36 def map_positive
37   2 * abs + (self > 0 ? 0 : 1)
38 end