Tutorial by Examples: f

You can add protocols to standard classes to extends their functionality: @protocol EncodableToString <NSObject> - (NSString *)toString; @end @interface NSDictionary (XYZExtended) <EncodableToString> @end @implementation NSDictionary (XYZExtended) - (NSString *)toString { ...
Using filterUsingPredicate: This Evaluates a given predicate against the arrays content and return objects that match. Example: NSMutableArray *array = [NSMutableArray array]; [array setArray:@[@"iOS",@"macOS",@"tvOS"]]; NSPredicate *predicate = [N...
if #available(iOS 9, *) { // iOS 9 } else { // iOS 8 or earlier }
Foreword Git can work with video game development out of the box. However the main caveat is that versioning large (>5 MB) media files can be a problem over the long term as your commit history bloats - Git simply wasn't originally built for versioning binary files. The great news is that since...
When initializing a Git repository for Unity development, there are a couple of things that need to be done. Unity Ignore Folders Not everything should be versioned in the repository. You can add the template below to your .gitignore file in the root of your repository. Or alternatively, you can c...
Int("123") // Returns 123 of Int type Int("abcd") // Returns nil Int("10") // Returns 10 of Int type Int("10", radix: 2) // Returns 2 of Int type Double("1.5") // Returns 1.5 of Double type Double("abcd") // Returns nil Note that do...
To show a message box when the form has been shown: Public Class Form1 Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown MessageBox.Show("Hello, World!") End Sub End Class To show a message box before the form has been shown: Public Cla...
In this example we will calculate the squared deviance for each column in a data frame, in this case the mtcars. Option A: integer index squared_deviance <- vector("list", length(mtcars)) for (i in seq_along(mtcars)){ squared_deviance[[i]] <- (mtcars[[i]] - mean(mtcars[[i]]))^2...
To illustrate the effect of good for loop construction, we will calculate the mean of each column in four different ways: Using a poorly optimized for loop Using a well optimized for for loop Using an *apply family of functions Using the colMeans function Each of these options will be shown...
A complete Fortran program is made up from a number of distinct program units. Program units are: main program function or subroutine subprogram module or submodule block data program unit The main program and some procedure (function or subroutine) subprograms may be provided by a languag...
iex> ~w(a b c) ["a", "b", "c"]
iex> ~w(a b c)a [:a, :b, :c]
for a large number of files which may need to be operated on in a similar process and with well structured file names. firstly a vector of the file names to be accessed must be created, there are multiple options for this: Creating the vector manually with paste0() files <- paste0("f...
#include <stdio.h> #define ARRLEN (10) int main (void) { int n[ ARRLEN ]; /* n is an array of 10 integers */ size_t i, j; /* Use size_t to address memory, that is to index arrays, as its guaranteed to be wide enough to address all of the possible availab...
git diff HEAD^ HEAD This will show the changes between the previous commit and the current commit.
Freeing memory twice is undefined behavior, e.g. int * x = malloc(sizeof(int)); *x = 9; free(x); free(x); Quote from standard(7.20.3.2. The free function of C99 ): Otherwise, if the argument does not match a pointer earlier returned by the calloc, malloc, or realloc function, or if the sp...
Using an incorrect format specifier in the first argument to printf invokes undefined behavior. For example, the code below invokes undefined behavior: long z = 'B'; printf("%c\n", z); Here is another example printf("%f\n",0); Above line of code is undefined behavior. %...
These examples assume that you already know what Java 7's NIO is in general, and you are used to writing code using java.io.File. Use these examples as a means to quickly find more NIO-centric documentation for migrating. There is much more to Java 7's NIO such as memory-mapped files or opening a Z...
instance Monoid [a] where mempty = [] mappend = (++) Checking the Monoid laws for this instance: mempty `mappend` x = x <-> [] ++ xs = xs -- prepending an empty list is a no-op x `mappend` mempty = x <-> xs ++ [] = xs -- appending an empty list is a no-op x...
mconcat :: [a] -> a is another method of the Monoid typeclass: ghci> mconcat [Sum 1, Sum 2, Sum 3] Sum {getSum = 6} ghci> mconcat ["concat", "enate"] "concatenate" Its default definition is mconcat = foldr mappend mempty.

Page 87 of 457