Tutorial by Examples: c

Fortran 2003 introduced intrinsic modules which provide access to special named constants, derived types and module procedures. There are now five standard intrinsic modules: ISO_C_Binding; supporting C interoperability; ISO_Fortran_env; detailing the Fortran environment; IEEE_Exceptions, IEEE_...
Say we have an enum DayOfWeek: enum DayOfWeek { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; } An enum is compiled with a built-in static valueOf() method which can be used to lookup a constant by its name: String dayName = DayOfWeek.SUNDAY.name(); assert dayName.equal...
It's good practice to document your work for later use, especially if you are coding for a dynamic workload. Good comments should explain why the code is doing something, not what the code is doing. Function Bonus(EmployeeTitle as String) as Double If EmployeeTitle = "Sales" Then ...
Given a sequence of steps we use repeatedly, it's often handy to store it in a function. Pipes allow for saving such functions in a readable format by starting a sequence with a dot as in: . %>% RHS As an example, suppose we have factor dates and want to extract the year: library(magrittr) ...
This topic specifically talks about UTF-8 and considerations for using it with a database. If you want more information about using databases in PHP then checkout this topic. Storing Data in a MySQL Database: Specify the utf8mb4 character set on all tables and text columns in your database. ...
If you need to match characters that are a part of the regular expression syntax you can mark all or part of the pattern as a regex literal. \Q marks the beginning of the regex literal. \E marks the end of the regex literal. // the following throws a PatternSyntaxException because of the un-close...
The following code will print the arguments to the program, and the code will attempt to convert each argument into a number (to a long): #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <limits.h> int main(int argc, char* argv[]) { for (int ...
Python 2.x2.7 To import a module through a function call, use the importlib module (included in Python starting in version 2.7): import importlib random = importlib.import_module("random") The importlib.import_module() function will also import the submodule of a package directly: c...
-- Create an index for column 'name' in table 'my_table' CREATE INDEX idx_name ON my_table(name);
A unique index prevents the insertion of duplicated data in a table. NULL values can be inserted in the columns that form part of the unique index (since, by definition, a NULL value is different from any other value, including another NULL value) -- Creates a unique index for column 'name' in tabl...
There is a limit to the depth of possible recursion, which depends on the Python implementation. When the limit is reached, a RuntimeError exception is raised: def cursing(depth): try: cursing(depth + 1) # actually, re-cursing except RuntimeError as RE: print('I recursed {} times!'....
To share files or to host simple websites(http and javascript) in your local network, you can use Python's builtin SimpleHTTPServer module. Python should be in your Path variable. Go to the folder where your files are and type: For python 2: $ python -m SimpleHTTPServer <portnumber> For p...
Suppose we want to write a factory function that accepts an arbitrary list of arguments and passes those arguments unmodified to another function. An example of such a function is make_unique, which is used to safely construct a new instance of T and return a unique_ptr<T> that owns the instan...
Defining a member block inside a resource creates a route that can act on an individual member of that resource-based route: resources :posts do member do get 'preview' end end This generates the following member route: get '/posts/:id/preview', to: 'posts#preview' # preview_post_p...
If you are building a function that may be heavy on the processor (either clientside or serverside) you may want to consider a memoizer which is a cache of previous function executions and their returned values. This allows you to check if the parameters of a function were passed before. Remember, p...
# Create a sample DF df = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC')) # Show DF df A B C 0 -0.467542 0.469146 -0.861848 1 -0.823205 -0.167087 -0.759942 2 -1.508202 1.361894 -0.166701 3 0.394143 -0.287349 -0.978102 4 -0.160431 1.054736 -0.785250 ...
The specifier override has a special meaning in C++11 onwards, if appended at the end of function signature. This signifies that a function is Overriding the function present in base class & The Base class function is virtual There is no run time significance of this specifier as is mainl...
With virtual member functions: #include <iostream> struct X { virtual void f() { std::cout << "X::f()\n"; } }; struct Y : X { // Specifying virtual again here is optional // because it can be inferred from X::f(). virtual void f() { std::cout <&lt...
A syntactic extension that lets you write \case in place of \arg -> case arg of. Consider the following function definition: dayOfTheWeek :: Int -> String dayOfTheWeek 0 = "Sunday" dayOfTheWeek 1 = "Monday" dayOfTheWeek 2 = "Tuesday" dayOfTheWeek 3 = "W...
A typical use case for a filter is to remove values from an array. In this example we pass in an array and remove any nulls found in it, returning the array. function removeNulls() { return function(list) { for (var i = list.length - 1; i >= 0; i--) { if (typeof list[i...

Page 132 of 826