Created
January 14, 2015 13:46
-
-
Save eccstartup/36637d96355bd5ca8188 to your computer and use it in GitHub Desktop.
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 characters
module MyMacros | |
export @map, @apply, @filter, @foldr, @foldr1, @foldl, @foldl1, @nobrace, @nobrace1 | |
macro map(f, args...) | |
quote | |
map($f,$(args...)) | |
end | |
end | |
macro apply(f, args...) | |
quote | |
apply($f, $(args...)) | |
end | |
end | |
macro filter(f, args...) | |
quote | |
filter($f, $(args...)) | |
end | |
end | |
macro foldr(op, v0, itr...) | |
quote | |
foldr($op, $v0, $(itr...)) | |
end | |
end | |
macro foldr1(op, itr...) | |
quote | |
foldr($op, $(itr...)) | |
end | |
end | |
macro foldl(op, v0, itr...) | |
quote | |
foldl($op, $v0, $(itr...)) | |
end | |
end | |
macro foldl1(op, itr...) | |
quote | |
foldl($op, $(itr...)) | |
end | |
end | |
macro nobrace(f, args...) | |
quote | |
$f($(args...)) | |
end | |
end | |
macro nobrace1(args...) | |
quote | |
begin | |
$(args...) | |
end | |
end | |
end | |
end |
Author
eccstartup
commented
Jan 15, 2015
julia> @nobrace map x->x+1 1:10
10-element Array{Int64,1}:
2
3
4
5
6
7
8
9
10
11
julia> @nobrace map (+) 1:10 11:20
10-element Array{Int64,1}:
12
14
16
18
20
22
24
26
28
30
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment