September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
8
Task/Metaprogramming/Kotlin/metaprogramming.kotlin
Normal file
8
Task/Metaprogramming/Kotlin/metaprogramming.kotlin
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// version 1.0.6
|
||||
|
||||
infix fun Double.pwr(exp: Double) = Math.pow(this, exp)
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val d = 2.0 pwr 8.0
|
||||
println(d)
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
say "Foo = $foo\n"; # normal double quotes
|
||||
say Q:qq 【Foo = $foo\n】; # a more explicit derivation, new quotes
|
||||
10
Task/Metaprogramming/Racket/metaprogramming-1.rkt
Normal file
10
Task/Metaprogramming/Racket/metaprogramming-1.rkt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#lang racket
|
||||
|
||||
(define-syntax-rule (list-when test body)
|
||||
(if test
|
||||
body
|
||||
'()))
|
||||
|
||||
(let ([not-a-string 42])
|
||||
(list-when (string? not-a-string)
|
||||
(string->list not-a-string)))
|
||||
8
Task/Metaprogramming/Racket/metaprogramming-2.rkt
Normal file
8
Task/Metaprogramming/Racket/metaprogramming-2.rkt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(require (for-syntax syntax/parse))
|
||||
|
||||
(define-syntax list-when
|
||||
(syntax-parser
|
||||
[(_ test:expr body:expr)
|
||||
#'(if test
|
||||
body
|
||||
null)]))
|
||||
|
|
@ -9,12 +9,12 @@ var colors = Hash(
|
|||
'white' => "fff",
|
||||
)
|
||||
|
||||
colors.each { |color, code|
|
||||
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;
|
||||
say "blue".in_blue
|
||||
say "red".in_red
|
||||
say "white".in_white
|
||||
|
|
|
|||
3
Task/Metaprogramming/Zkl/metaprogramming-1.zkl
Normal file
3
Task/Metaprogramming/Zkl/metaprogramming-1.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#define name [0|1]
|
||||
#if [0|1|name]
|
||||
#else, #endif
|
||||
3
Task/Metaprogramming/Zkl/metaprogramming-2.zkl
Normal file
3
Task/Metaprogramming/Zkl/metaprogramming-2.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//Full zkl functionality but limited access to the parse stream; only #defines
|
||||
#ifdef name
|
||||
#fcn name {code}
|
||||
3
Task/Metaprogramming/Zkl/metaprogramming-3.zkl
Normal file
3
Task/Metaprogramming/Zkl/metaprogramming-3.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// Shove text into the parse stream
|
||||
#text name text
|
||||
#tokenize name, #tokenize f, #tokenize f(a)
|
||||
3
Task/Metaprogramming/Zkl/metaprogramming-4.zkl
Normal file
3
Task/Metaprogramming/Zkl/metaprogramming-4.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#<<<#
|
||||
text, any text, inside #<<<# pairs is ignored
|
||||
#<<<#
|
||||
8
Task/Metaprogramming/Zkl/metaprogramming-5.zkl
Normal file
8
Task/Metaprogramming/Zkl/metaprogramming-5.zkl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
string:=
|
||||
#<<<
|
||||
"here docs:
|
||||
all text in #<<< pairs is collected into one [long] line and passed
|
||||
verbatim to the tokenizer. Illustrated here as quoted (\") strings
|
||||
can not span lines.";
|
||||
#<<<
|
||||
println(string); // contains newlines
|
||||
4
Task/Metaprogramming/Zkl/metaprogramming-6.zkl
Normal file
4
Task/Metaprogramming/Zkl/metaprogramming-6.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
const{ var _n=-1; var [proxy] N=fcn{ _n+=1 } }
|
||||
const X=N; // → 0
|
||||
println(_n); // → 2 code time is after const time
|
||||
const Y=N,Z=N; // → 1,2
|
||||
Loading…
Add table
Add a link
Reference in a new issue