Last active
January 3, 2016 02:08
Revisions
-
grncdr revised this gist
Jan 13, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ macro thread { return #{ (function () { var $$_ = arguments.length > 1 ? [].slice.call(arguments) : arguments[0]; thread_body $$_ $body ...; return $$_ })($args (,) ...) } @@ -16,11 +16,11 @@ macro thread { macro thread_body { rule { $_ $first ...; $rest ... } => { $_ = $first ...; thread_body $_ $rest ... } rule {} => {} } -
grncdr revised this gist
Jan 13, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ macro thread_body { $rest ... } => { $_ = $first ...; thread_body $rest ... } rule {} => {} } -
grncdr created this gist
Jan 13, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ macro thread { case { $name ($args (,) ...) { $body ... } } => { var result = makeIdent('$_', #{$name}) return withSyntax($$_ = [result]) { console.log('here') return #{ (function () { var $$_ = arguments.length > 1 ? [].slice.call(arguments) : arguments[0]; thread_body $body ...; return $$_ })($args (,) ...) } } } } macro thread_body { rule { $first ...; $rest ... } => { $_ = $first ...; seq_body $rest ... } rule {} => {} } var y = thread (1) { second(1, $_, 3); last(something, $_) }