Tutorial by Examples

Although not traditionally considered loops, the @goto and @label macros can be used for more advanced control flow. One use case is when the failure of one part should lead to the retry of an entire function, often useful in input validation: function getsequence() local a, b @label start ...
The most common conditional in Julia is the if...else expression. For instance, below we implement the Euclidean algorithm for computing the greatest common divisor, using a conditional to handle the base case: mygcd(a, b) = if a == 0 abs(b) else mygcd(b % a, a) end The if...else for...
name = readline() if startswith(name, "A") println("Your name begins with A.") else println("Your name does not begin with A.") end Any expression, such as the if...else expression, can be put in statement position. This ignores its value but still execu...
Like any other expression, the return value of an if...else expression can be ignored (and hence discarded). This is generally only useful when the body of the expression has side effects, such as writing to a file, mutating variables, or printing to the screen. Furthermore, the else branch of an i...
pushunique!(A, x) = x in A ? A : push!(A, x) The ternary conditional operator is a less wordy if...else expression. The syntax specifically is: [condition] ? [execute if true] : [execute if false] In this example, we add x to the collection A only if x is not already in A. Otherwise, we jus...
For branching The short-circuiting conditional operators && and || can be used as lightweight replacements for the following constructs: x && y is equivalent to x ? y : x x || y is equivalent to x ? x : y One use for short-circuit operators is as a more concise way to test a ...
d = Dates.dayofweek(now()) if d == 7 println("It is Sunday!") elseif d == 6 println("It is Saturday!") elseif d == 5 println("Almost the weekend!") else println("Not the weekend yet...") end Any number of elseif branches may be used...
shift(x) = ifelse(x > 10, x + 1, x - 1) Usage: julia> shift(10) 9 julia> shift(11) 12 julia> shift(-1) -2 The ifelse function will evaluate both branches, even the one that is not selected. This can be useful either when the branches have side effects that must be evaluat...
A Mixin is a set of properties and methods that can be used in different classes, which don't come from a base class. In Object Oriented Programming languages, you typically use inheritance to give objects of different classes the same functionality; if a set of objects have some ability, you put th...
A simplest Oozie application is consists of a workflow logic file (workflow.xml), workflow properties file (job.properties/job.xml) and required JAR files, scripts and configuration files. Except the workflow properties file, all the other files should to be stored in a HDFS location. The workflow p...
MySQLi is a PHP Extension which enables PHP to communicate with MySQL Databases. MySQLi comes built in with PHP. MySQLi was introduced with PHP 5.0. For More details about Installations Refer official PHP MySQLi Documentation
Here is a class (Dog) creating its own dependency (Food): class Dog { public Dog() { var food = new Food(); this.eat(food); } } Here is the same class being injected with its dependency using constructor injection: class Dog { public Dog(Food food) { ...
Splits some partition into two partitions with another high bound. ALTER TABLE table_name SPLIT PARTITION old_partition AT (new_high_bound) INTO (PARTITION new_partition TABLESPACE new_tablespace, PARTITION old_partition)
Merge two partitions into single one ALTER TABLE table_name MERGE PARTITIONS first_partition, second_partition INTO PARTITION splitted_partition TABLESPACE new_tablespace
Overview Create a queue that we can send a message to. Oracle will notify our stored procedure that a message has been enqueued and should be worked. We'll also add some subprograms we can use in an emergency to stop messages from being deqeued, allow dequeuing again, and run a simple batch job t...
The JOIN operation performs a join between two tables, excluding any unmatched rows from the first table. From Oracle 9i forward, the JOIN is equivalent in function to the INNER JOIN. This operation requires an explicit join clause, as opposed to the CROSS JOIN and NATURAL JOIN operators. Example: ...
Once your project has been created, you can launch the app by typing $ sails lift By default, you can access the app in the browser on port 1337. The URL with the port is shown in the terminal. Another way to start the Sails app is with the node command: $ node app.js However, you lose some...
A map is an associative array or dictionary composed of (key, value) pairs. 1> M0 = #{}. #{} 2> M1 = #{ "name" => "john", "age" => "28" }. #{"age" => "28","name" => "john"} 3> M2 = #{ a => {M...
The next function is useful even without iterating. Passing a generator expression to next is a quick way to search for the first occurrence of an element matching some predicate. Procedural code like def find_and_transform(sequence, predicate, func): for element in sequence: if predi...
If you want to change an attribute of a control such as a textbox or label from another thread than the GUI thread that created the control, you will have to invoke it or else you might get an error message stating: "Cross-thread operation not valid: Control 'control_name' accessed from a th...

Page 588 of 1336