metaprogramming


Loop unrolling? in Julia with metaprogramming


is there a way to "metaprogrammatically" obtain a block of code with the following structure:
if r1 < R1
s = 1
elseif r1 < R2
s = 2
... etc until N
end
end
Thanks!
Check out Base.Cartesian.#nif
I think this should work for you...
julia> macroexpand(:(#nif 10 d->(r1 < R_d) d->begin s=d; break end))
:(if r1 < R_1 # REPL[9], line 1:
s = 1 # REPL[9], line 1:
break
else
if r1 < R_2 # REPL[9], line 1:
s = 2 # REPL[9], line 1:
break
else
if r1 < R_3 # REPL[9], line 1:
s = 3 # REPL[9], line 1:
break
else
if r1 < R_4 # REPL[9], line 1:
s = 4 # REPL[9], line 1:
break
else
if r1 < R_5 # REPL[9], line 1:
s = 5 # REPL[9], line 1:
break
else
if r1 < R_6 # REPL[9], line 1:
s = 6 # REPL[9], line 1:
break
else
if r1 < R_7 # REPL[9], line 1:
s = 7 # REPL[9], line 1:
break
else
if r1 < R_8 # REPL[9], line 1:
s = 8 # REPL[9], line 1:
break
else
if r1 < R_9 # REPL[9], line 1:
s = 9 # REPL[9], line 1:
break
else # REPL[9], line 1:
s = 10 # REPL[9], line 1:
break
end
end
end
end
end
end
end
end
end)

Related Links

Using Roslyn, if I have an IdentifierNameSyntax, can I find the member type it refers to (field, property, method…)
Elixir - Define functions in module by metaprogramming
Disambiguate the various quoting mechanisms in Julia metaprogramming
How to initialize list using macros and then generate same set of functions in 2 different modules?
Type-safe metaprogramming? Using strings to query ceylon.language for meta information?
Interpolating an Expression into an Expression
Loop unrolling? in Julia with metaprogramming
Macro for a function template: escaping issues
Macro that defines macro returning struct constant
Array of Expressions to an Array Definition
Code generation from restricted set of input
System of equations using metaprogramming
How to define a partial copy constructor metaprogramically in Julia?
How to interpolate into a Julia “for” expression?
Sending a keyword list to a macro and using bind_quoted
Runtime meta programming in ceylon

Categories

HOME
algorithm
turing-machines
wakanda
gradient
rom
pyqt4
watson-conversation
startup
mod-security
rtf
favicon
selenium-ide
altera
asp.net-mvc-viewmodel
microsoft-ocr
visual-studio-extensions
asymptotic-complexity
bioinformatics
sqsh
google-earth
left-join
twos-complement
android-maps-extensions
google-earth-engine
node-mssql
cin
logback-groovy
oim
openrasta
robomongo
spring-integration-sftp
rserve
openblas
page-replacement
carrot2
pdf-conversion
seq
swingworker
rxtx
segment-io
jboss-tools
hclust
cifilter
xdoclet
qt5.2
doctype
sql-server-data-tools
mirror
avahi
dnssec
canvg
bufferedinputstream
node-serialport
osc
diff3
umlgraph
showdialog
addressing-mode
structuremap3
deform
rickshaw
unix-socket
parallel-testing
grails-plugin-rabbitmq
spring-remoting
paste
getopt
high-resolution
scrypt
mongohq
intersect
extconf.rb
multiplexing
convention
role
creole
ie-compatibility-mode
updatesourcetrigger
vs-android
binomial-heap
silverlight-oob
lalr
wordprocessingml
xpsdocument
localizable.strings
mathematical-typesetting

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App