Login
|
Signup
langref.org
-
ruby
,
erlang
, and
clojure
add..
all
cpp
csharp
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Numbers
Output
Right Space pad a number
Given the number 1024 right pad it to 6 characters
"1024 "
ruby
1024.to_s.ljust(6)
1024.to_s.ljust(6)
erlang
Formatted = io_lib:format("~-6B", [1024]),
-module(rightspace).
-export([start/0]).
start() ->
Formatted = io_lib:format("~-6B", [1024]),
io:format("~s~n", [Formatted]).
erlang
io:format("~-6B~n", [1024]).
-module(rightspace).
-export([start/0]).
start() ->
io:format("~-6B~n", [1024]).
clojure
(let [s (str 1024)
l (count s)]
(str s (reduce str (repeat (- 6 l) " "))))
(let [s (str 1024)
l (count s)]
(str s (reduce str (repeat (- 6 l) " "))))
Submit a new solution for
ruby
,
erlang
, or
clojure
There are 28 other solutions in
additional
languages (
cpp
,
csharp
,
fantom
,
fsharp
...)