19 yo student *and* a full-time developer.
Building with Rails currently, exploring new frontiers.
I enjoy functional programming, Linux, FOSS, refactoring and mentoring :)
defmoduleReadableTimedo@minute60@hour@minute*60@day@hour*24@year@day*365@specfrom_seconds(non_neg_integer)::String.t()deffrom_seconds(0),do:"now"deffrom_seconds(time)do[year:&div(&1,@year),day:&(&1|>div(@day)|>rem(365)),hour:&(&1|>div(@hour)|>rem(24)),minute:&(&1|>div(@minute)|>rem(60)),second:&rem(&1,60)]|>Enum.map(fn{word,quotient}->{quotient.(time),pluralize(word,quotient.(time))}end)|>Enum.filter(fn{quotient,_}->quotient>0end)|>Enum.map(fn{quotient,word}->"#{quotient}#{word}"end)|>to_sentence()end@specpluralize(String.t(),non_neg_integer)::String.t()defppluralize(word,1),do:worddefppluralize(word,n)whenn>=0,do:"#{word}s"@specto_sentence([String.t()])::String.t()defpto_sentence([elem]),do:elemdefpto_sentence(list)do(list|>Enum.slice(0..-2)|>Enum.join(", "))<>" and "<>List.last(list)endend
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Elixir: