Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,17 +1,22 @@
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
do
inc("23")
end
inc(s:STRING)
do
io.put_string (s.to_integer.plus (1).out)
end
feature {NONE}
make
do
io.put_string (increment_numerical_string ("7"))
io.new_line
io.put_string (increment_numerical_string ("99"))
end
increment_numerical_string (s: STRING): STRING
-- String 's' incremented by one.
do
Result := s.to_integer.plus (1).out
end
end

View file

@ -0,0 +1,6 @@
increment1 = fn n -> to_string(String.to_integer(n) + 1) end
# Or piped
increment2 = fn n -> n |> String.to_integer |> +1 |> to_string end
increment1.("1")
increment2.("100")

View file

@ -0,0 +1,2 @@
iex(1)> (List.to_integer('12345') + 1) |> to_char_list
'12346'

View file

@ -1 +1 @@
+(s::String, n::Integer) = string(parseint(typeof(n), s) + n)
+(s::String, n::Integer) = string(parse(Int, s) + n)

View file

@ -1,8 +1,9 @@
// rust 0.9-pre
fn next_string(input: &str) -> String {
(input.parse::<i64>().unwrap() + 1).to_string()
}
fn main() {
let s = "-1";
let s = (from_str::<int>(s).unwrap() + 1).to_str();
assert_eq!(s, ~"0");
println(s);
let s2 = next_string(s);
println!("{:?}", s2);
}