Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
class BinaryTree<Data>(shared Data data, shared BinaryTree<Data>? left = null, shared BinaryTree<Data>? right = null) {
|
||||
|
||||
shared BinaryTree<NewData> myMap<NewData>(NewData f(Data d)) =>
|
||||
BinaryTree {
|
||||
data = f(data);
|
||||
left = left?.myMap(f);
|
||||
right = right?.myMap(f);
|
||||
};
|
||||
}
|
||||
|
||||
shared void run() {
|
||||
|
||||
value tree1 = BinaryTree {
|
||||
data = 3;
|
||||
left = BinaryTree {
|
||||
data = 4;
|
||||
};
|
||||
right = BinaryTree {
|
||||
data = 5;
|
||||
left = BinaryTree {
|
||||
data = 6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
tree1.myMap(print);
|
||||
print("");
|
||||
|
||||
value tree2 = tree1.myMap((x) => x * 333.33);
|
||||
tree2.myMap(print);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue