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

@ -0,0 +1,18 @@
REPORT z_test_rosetta_collection.
CLASS lcl_collection DEFINITION CREATE PUBLIC.
PUBLIC SECTION.
METHODS: start.
ENDCLASS.
CLASS lcl_collection IMPLEMENTATION.
METHOD start.
DATA(itab) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ).
cl_demo_output=>display( itab ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
NEW lcl_collection( )->start( ).

View file

@ -0,0 +1,9 @@
empty_list = []
list = [1,2,3,4,5]
length(list) #=> 5
[0 | list] #=> [0,1,2,3,4,5]
hd(list) #=> 1
tl(list) #=> [2,3,4,5]
Enum.at(list,3) #=> 4
list ++ [6,7] #=> [1,2,3,4,5,6,7]
list -- [4,2] #=> [1,3,5]

View file

@ -0,0 +1,5 @@
empty_tuple = {} #=> {}
tuple = {0,1,2,3,4} #=> {0, 1, 2, 3, 4}
tuple_size(tuple) #=> 5
elem(tuple, 2) #=> 2
put_elem(tuple,3,:atom) #=> {0, 1, 2, :atom, 4}

View file

@ -0,0 +1,4 @@
list = [{:a,1},{:b,2}] #=> [a: 1, b: 2]
list == [a: 1, b: 2] #=> true
list[:a] #=> 1
list ++ [c: 3, a: 5] #=> [a: 1, b: 2, c: 3, a: 5]

View file

@ -0,0 +1,7 @@
empty_map = Map.new #=> %{}
map = %{:a => 1, 2 => :b} #=> %{2 => :b, :a => 1}
map[:a] #=> 1
map[2] #=> :b
# If you pass duplicate keys when creating a map, the last one wins:
%{1 => 1, 1 => 2} #=> %{1 => 2}

View file

@ -0,0 +1,3 @@
map = %{:a => 1, :b => 2} #=> %{a: 1, b: 2}
map.a #=> 1
%{map | :a => 2} #=> %{a: 2, b: 2}

View file

@ -0,0 +1,10 @@
empty_set = HashSet.new #=> #HashSet<[]>
set1 = Enum.into(1..4,HashSet.new) #=> #HashSet<[2, 3, 4, 1]>
Set.size(set1) #=> 4
Set.member?(set1,3) #=> true
Set.put(set1,9) #=> #HashSet<[2, 3, 4, 1, 9]>
set2 = Enum.into([0,2,4,6],HashSet.new) #=> #HashSet<[0, 2, 6, 4]>
Set.union(set1,set2) #=> #HashSet<[0, 2, 6, 4, 3, 1]>
Set.intersection(set1,set2) #=> #HashSet<[2, 4]>
Set.difference(set1,set2) #=> #HashSet<[3, 1]>
Set.subset?(set1,set2) #=> false

View file

@ -2,4 +2,4 @@ var array = [];
array.push('abc');
array.push(123);
array.push(new MyClass);
alert( array[2] );
console.log( array[2] );

View file

@ -1,5 +1,5 @@
var map = {};
map['foo'] = 'xyz'; //equivalent to: map.foo = 'xyz';
map['bar'] = new MyClass; //equivalent to: map.bar = new MyClass;
map['1x; ~~:-b'] = 'text'; //no equivalent
alert( map['1x; ~~:-b'] );
var obj = {};
obj['foo'] = 'xyz'; //equivalent to: obj.foo = 'xyz';
obj['bar'] = new MyClass; //equivalent to: obj.bar = new MyClass;
obj['1x; ~~:-b'] = 'text'; //no equivalent
console.log(obj['1x; ~~:-b']);

View file

@ -6,3 +6,4 @@ m = matrix(1,1);
s = Set(v);
l = List(v);
vs = vectorsmall(0);
M = Map()

View file

@ -1,3 +1,4 @@
listput(l, "hello world")
v=concat(v, [1,2,3]);
v=concat(v, 4);
mapput(M, "key", "value");

View file

@ -3,14 +3,14 @@ my @array = 1,2,3;
@array.push: 4,5,6;
# Hash
my %hash = a => 1, b => 2;
my %hash = 'a' => 1, 'b' => 2;
%hash<c d> = 3,4;
%hash.push: e => 5, f => 6;
%hash.push: 'e' => 5, 'f' => 6;
# KeySet
my $s = KeySet.new: <a b c>;
# SetHash
my $s = SetHash.new: <a b c>;
$s = <d e f>;
# KeyBag
my $b = KeyBag.new: <b a k l a v a>;
$b.push: <d e f>;
# BagHash
my $b = BagHash.new: <b a k l a v a>;
$b = <a b c>;

View file

@ -1,6 +1,6 @@
# List
my @list := 1,2,3;
my @newlist := @list, 4,5,6;
my @newlist := |@list, 4,5,6; # |@list will slip @list into the surrounding list instead of creating a list of lists
# Set
my $set = set <a b c>;
@ -8,4 +8,4 @@ my $newset = $set <d e f>;
# Bag
my $bag = bag <b a k l a v a>;
my $newbag = $bag <b e e f>;
my $newbag = $bag <b e e f>;