Tutorial by Examples: bst

Dim filename As String = "c:\path\to\file.txt" If System.IO.File.Exists(filename) Then Dim writer As New System.IO.StreamWriter(filename) writer.Write("Text to write" & vbCrLf) 'Add a newline writer.close() End If
countMatches method from org.apache.commons.lang3.StringUtils is typically used to count occurences of a substring or character in a String: import org.apache.commons.lang3.StringUtils; String text = "One fish, two fish, red fish, blue fish"; // count occurrences of a substring Str...
Use .slice() to extract substrings given two indices: var s = "0123456789abcdefg"; s.slice(0, 5); // "01234" s.slice(5, 6); // "5" Given one index, it will take from that index to the end of the string: s.slice(10); // "abcdefg"
An abstract class is a class that cannot be instantiated. Abstract classes can define abstract methods, which are methods without any body, only a definition: abstract class MyAbstractClass { abstract public function doSomething($a, $b); } Abstract classes should be extended by a child cla...
A method defined in an interface is by default public abstract. When an abstract class implements an interface, any methods which are defined in the interface do not have to be implemented by the abstract class. This is because a class that is declared abstract can contain abstract method declaratio...
Abstract factory pattern provides a way to obtain an coherent collection of objects through a collection of factories functions. As for every pattern, coupling is reduced by abstracting the way a set of objects are created, so that the user code is unaware of the many details of the objects he needs...
Category theory is a modern mathematical theory and a branch of abstract algebra focused on the nature of connectedness and relation. It is useful for giving solid foundations and common language to many highly reusable programming abstractions. Haskell uses Category theory as inspiration for some o...
${parameter:-word} If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted. $ unset var $ echo "${var:-XX}" # Parameter is unset -> expansion XX occurs XX $ var="" # Parameter is null ...
For the character entity character(len=5), parameter :: greeting = "Hello" a substring may be referenced with the syntax greeting(2:4) ! "ell" To access a single letter it isn't sufficient to write greeting(1) ! This isn't the letter "H" but greeting(1:...
Information The ABSTRACT and FINAL additions to the METHODS and CLASS statements allow you to define abstract and final methods or classes. An abstract method is defined in an abstract class and cannot be implemented in that class. Instead, it is implemented in a subclass of the class. Abstra...
An extensible derived type may be abstract type, abstract :: base_type end type Such a derived type may never be instantiated, such as by type(base_type) t1 allocate(type(base_type) :: t2) but a polymorphic object may have this as its declared type class(base_type), allocatable :: t1 o...
iex> my_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." iex> String.slice my_string, 6..10 "ipsum"
strpos can be understood as the number of bytes in the haystack before the first occurrence of the needle. var_dump(strpos("haystack", "hay")); // int(0) var_dump(strpos("haystack", "stack")); // int(3) var_dump(strpos("haystack", "stackoverf...
The .indexOf method returns the index of a substring inside another string (if exists, or -1 if otherwise) 'Hellow World'.indexOf('Wor'); // 7 .indexOf also accepts an additional numeric argument that indicates on what index should the function start looking "harr dee harr dee harr&quot...
The following design pattern is categorized as a creational pattern. An abstract factory is used to provide an interface for creating families of related objects, without specifying concrete classes and can be used to hide platform specific classes. interface Tool { void use(); } interf...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[contains(@name,'Ear')] or //*[contains(@name,'Ear...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[contains(lower-case(@name),'ear')] or //*[contain...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[starts-with(lower-case(@name),'ear')] or //*[star...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[ends-with(lower-case(@type),'tar')] or //*[ends-w...
Disclaimer: the examples presented here are only for the purpose of showing the use of abstract classes and inheritance and may not necessarily be of a practical use. Also, there is no sich thing as polymorphic in MATLAB and therefore the use of abstract classes is limited. This example is to show w...

Page 2 of 5