Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Metaprogramming/Sidef/metaprogramming-1.sidef
Normal file
7
Task/Metaprogramming/Sidef/metaprogramming-1.sidef
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class Number {
|
||||
method ⊕(arg) {
|
||||
self + arg
|
||||
}
|
||||
}
|
||||
|
||||
say (21 ⊕ 42)
|
||||
20
Task/Metaprogramming/Sidef/metaprogramming-2.sidef
Normal file
20
Task/Metaprogramming/Sidef/metaprogramming-2.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var colors = Hash(
|
||||
'black' => "000",
|
||||
'red' => "f00",
|
||||
'green' => "0f0",
|
||||
'yellow' => "ff0",
|
||||
'blue' => "00f",
|
||||
'magenta' => "f0f",
|
||||
'cyan' => "0ff",
|
||||
'white' => "fff",
|
||||
)
|
||||
|
||||
for color,code in colors {
|
||||
String.def_method("in_#{color}", func (self) {
|
||||
'<span style="color: #' + code + '">' + self + '</span>'
|
||||
})
|
||||
}
|
||||
|
||||
say "blue".in_blue
|
||||
say "red".in_red
|
||||
say "white".in_white
|
||||
Loading…
Add table
Add a link
Reference in a new issue