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

Meta-modeling crud FROM/JOIN/WHERE statement fragments for higher-level analysis
Elixir: eval'ing code in module context using Code.eval_quoted/3
What is Declarative Meta-Programming?
Reconsolidate protocols in Elixir 1.2 or higher
Inserting an AST into a quote do end block without unquoting it
Transform quoted elixir code to a code string
Pattern matching benchmarking : Compiletime lookup vs Runtime lookup in D
Meta construction capabilities?
How to manipulate the value of variables based on an array of symbols in Julia?
Multiple #:build macros
Julia automatically generate functions and export them
Dealing with end keyword in macros for array indices
Implementation of AnyMap and runtime overhead of `struct Port(u32);`
Can function application be overriden with Macro in Elixir?
“Registering” trait implementations + factory method for trait objects
Statement list composition

Categories

HOME
microsoftgraph
porting
polymer
string
telegram
css3
fftw
devise
newrelic
spring-data-mongodb
google-apps
bookmarks
pcl-crypto
vimdiff
activecollab
naivebayes
supervisor
gkturnbasedmatch
frequency-distribution
firefox-addon
feathersjs
android-7.0-nougat
connector
guzzle
systemtime
parcelable
php-mysqlidb
tosca
jquery-callback
dynamically-generated
gmock
entity-relationship-model
underscore.js
tpm
errbot
twiml
dotspatial
eviews
livelink
cognos-bi
git-squash
fstream
memory-address
simplecv
login-script
reverse
slacktextviewcontroller
hivemq
apic
docfx
playframework-2.1
flatmap
odroid
mongoose-schema
p4merge
setup.py
postgresql-8.4
wc
procfile
jide
reportservice2010
podscms
corruption
java-6
cup
payload
mouseleave
offline.js
atlas
mapxtreme
seek
android-dateutils
deep
riot
spreadjs
uiactionsheet
user-management
phpgrid
decimalformat
vigenere
django-urls
intel-c++
android-launcher
canalyzer
zscript
baasbox
apache-commons-daemon
botan
kubuntu
shopizer
procedural-programming
at-job
execve
punycode
grails-plugin-rabbitmq
terminate
file-not-found
clickbank
dtmf
ebay-lms
asplinkbutton
extreme-programming
nokia-s40
web-farm
oracle-enterprise-linux
mbeans
appledoc
qglwidget
presentation-layer
rowlex
aspmenu
pagemethods
interop-domino
todos
sqlobject
entitykey
great-circle

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