Tutorial by Examples: dp

We prepare a file called reverser.ml with the following contents: let acc = ref [] in try while true do acc := read_line () :: !acc; done with End_of_file -> print_string (String.concat "\n" !acc) We then compile our program using ...
This is a minimalist Hello World example that uses only the most basic Android tools. Requirements and assumptions Oracle JDK 1.7 or later Android SDK Tools (just the command line tools) This example assumes Linux. You may have to adjust the syntax for your own platform. Setting up the And...
This is a shell session showing how to create a "Hello world" program and run it with Cargo: $ cargo new hello --bin $ cd hello $ cargo run Compiling hello v0.1.0 (file:///home/rust/hello) Running `target/debug/hello` Hello, world! After doing this, you can edit the progra...
DROP PROCEDURE if exists displayNext100WithName; DELIMITER $$ CREATE PROCEDURE displayNext100WithName ( nStart int, tblName varchar(100) ) BEGIN DECLARE thesql varchar(500); -- holds the constructed sql string to execute -- expands the sizing of the output buffer to accomoda...
HTML comments (optionally preceded by whitespace) will cause code (on the same line) to be ignored by the browser also, though this is considered bad practice. One-line comments with the HTML comment opening sequence (<!--): Note: the JavaScript interpreter ignores the closing characters of H...
There are several good examples of using lambdas as a FunctionalInterface in simple scenarios. A fairly common use case that can be improved by lambdas is what is called the Execute-Around pattern. In this pattern, you have a set of standard setup/teardown code that is needed for multiple scenarios ...
On Debian-based distributions, including Ubuntu, the most straightforward way is to use the .deb installation file. Go to the Scala website. Choose the version you want to install then scroll down and look for scala-x.x.x.deb. You can install the scala deb from command line: sudo dpkg -i scala-x.x...
Collections in Java only work for objects. I.e. there is no Map<int, int> in Java. Instead, primitive values need to be boxed into objects, as in Map<Integer, Integer>. Java auto-boxing will enable transparent use of these collections: Map<Integer, Integer> map = new HashMap<&g...
Mercurial makes it easy to share your work, and to pull in contributions from other developers. This involves three key steps; cloning, pulling, and pushing. Clone To copy a remote repository to your local disk you "clone" it. To do so simply pass the remote URL you'd like to clone from....
Sometimes it is necessary or desirable to place the legend outside the plot. The following code shows how to do it. import matplotlib.pylab as plt fig, ax = plt.subplots(1, 1, figsize=(10,6)) # make the figure with the size 10 x 6 inches fig.suptitle('Example of a Legend Being Placed Outside of...
When defining a function, use {param1, param2, …} to specify named parameters: void enableFlags({bool bold, bool hidden}) { // ... } When calling a function, you can specify named parameters using paramName: value enableFlags(bold: true, hidden: false);
vagrant up By default the box will be provisioned.
Fix takes a "template" type and ties the recursive knot, layering the template like a lasagne. newtype Fix f = Fix { unFix :: f (Fix f) } Inside a Fix f we find a layer of the template f. To fill in f's parameter, Fix f plugs in itself. So when you look inside the template f you find a...
Compare the definition of Free to that of Fix: data Free f a = Return a | Free (f (Free f a)) newtype Fix f = Fix { unFix :: f (Fix f) } In particular, compare the type of the Free constructor with the type of the Fix constructor. Free layers up a functor just like Fix, except ...
Create SharedPreferences BuyyaPref SharedPreferences pref = getApplicationContext().getSharedPreferences("BuyyaPref", MODE_PRIVATE); Editor editor = pref.edit(); Storing data as KEY/VALUE pair editor.putBoolean("key_name1", true); // Saving boolean - true/false ...
The following code can be entered in a Tcl shell (tclsh), or into a script file and run through a Tcl shell: puts "Hello, world!" It gives the string argument Hello, world! to the command puts. The puts command writes its argument to standard out (your terminal in interactive mode) an...
PrimitiveBoxed TypeMemory Size of primitive / boxedbooleanBoolean1 byte / 16 bytesbyteByte1 byte / 16 bytesshortShort2 bytes / 16 bytescharChar2 bytes / 16 bytesintInteger4 bytes / 16 byteslongLong8 bytes / 16 bytesfloatFloat4 bytes / 16 bytesdoubleDouble8 bytes / 16 bytes Boxed objects always requ...
When you need to set a pixel value for something like Paint.setTextSize but still want it be scaled based on the device, you can convert dp and sp values. DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, m...
Using the Authors table in the Library Database CREATE PROCEDURE GetName ( @input_id INT = NULL, --Input parameter, id of the person, NULL default @name VARCHAR(128) = NULL --Input parameter, name of the person, NULL default ) AS BEGIN SELECT Name + ' is from ' + Country...
SOAP services can publish metadata that describes the methods that may be invoked by clients. Clients can use tools such as Visual Studio to automatically generate code (known as client proxies). The proxies hide the complexity of invoking a service. To invoke a service, one merely invokes a metho...

Page 6 of 21