Created
June 14, 2016 13:32
-
-
Save Troush/7efbf8fe7efd2016224c705db4b5ff69 to your computer and use it in GitHub Desktop.
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
def compact_units([] = vals, units) do | |
"#{units}" | |
end | |
def compact_units([h |[]] = vals, units) do | |
"#{h} #{compact_units([], units)}" | |
end | |
def compact_units([h|t] = vals, units) do | |
"#{h} x #{compact_units(t, units)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
compact_units([obj.length, obj.height, obj.width], "m") // 2.5 x 1.4 x 2 m