Programming Tricks
Julia
TODO 📅
UnitRange to Array
a UnitRange
is a specific type of range that represents
a sequence of integers with a step of 1
UnitRange
objects are "lazy" and efficient. They do not
allocate memory for all elements in the range until explicitly converted
to a concrete array (e.g., using collect()
)
views
A view
is essentially a
pointer to a sub-section of another vector,
but not a standalone vector itself
1 | one2ten = collect(1:10); |
@views
is a macro that converts sliced arrays into views (pointers are much cheaper than creating copies of arrays). For more information on how to use theview
syntax correctly
Conditional Compilation In C++
Using g++ only
conditional.cpp
1 |
|
-DDEBUG args
1 | $ g++ -Wall -Wextra -Wconversion conditional.cpp -o conditional |
Using CMakeLists.txt add_definitions
1 | cmake_minimum_required(VERSION 3.2) |
without debug
1 | $ cmake .. |
with debug
1 | $ cmake -DDEBUG=ON .. |