Tutorial by Examples

// Checks a string to see if it is a palindrome bool function IsPalindrome(string input) { if (input.size() <= 1) { return true; } else if (input[0] == input[input.size() - 1]) { return IsPalindrome(input.substr(1,input.size() - 2)); } else { r...
Custom events usually need custom event arguments containing information about the event. For example MouseEventArgs which is used by mouse events like MouseDown or MouseUp events, contains information about Location or Buttons which used to generate the event. When creating new events, to create a...
A cancelable event can be raised by a class when it is about to perform an action that can be canceled, such as the FormClosing event of a Form. To create such event: Create a new event arg deriving from CancelEventArgs and add additional properties for event data. Create an event using EventH...
If you have a list, and you want to use the elements of that list as the arguments to a function, what you want is apply: > (apply string-append (list "hello" " " "and hi" " " "are both words")) "hello and hi are both words" > (app...
; We make single line comments by writing out text after a semicolon
#| We make block comments like this |#
Functions in Racket can be created with the lambda form. The form takes a list of arguments and a body. (lambda (x y) (* x y)) In the example above, the function takes in two arguments and returns the result of multiplying them. > ((lambda (x y) (* x y)) 4 4) 16 > ((lambda (x y) (* x y)...
Download and install Visual Studio Community 2015 Open Visual Studio Community Click File -> New -> Project Click Templates -> Visual C++ -> Win32 Console Application and then name the project MyFirstProgram. Click Ok Click Next in the following window. Check the Empty proj...
Each Error object has a string property named stack that contains the stack trace:
Instrument your code with console.trace() calls that print current JavaScript call stacks:
Place assertions in your JavaScript code by calling console.assert() with the error condition as the first parameter. When this expression evaluates to false, you will see a corresponding console record:
In many instances, you will want to send data from the R server to the JS client. Here is a very simple example: library(shiny) runApp( list( ui = fluidPage( tags$script( "Shiny.addCustomMessageHandler('message', function(params) { alert(params); });" ), ...
Modern browsers provide a classList object to ease manipulation of the element's class attribute. Older browsers require direct manipulation of the element's className property. W3C DOM4 A simple method to add a class to an element is to append it to the end of the className property. This will no...
Thread.sleep causes the current thread to suspend execution for a specified period. This is an efficient means of making processor time available to the other threads of an application or other applications that might be running on a computer system. There are two overloaded sleep methods in the Thr...
To set a value in NSUserDefaults, you can use the following functions: Swift < 3 setBool(_:forKey:) setFloat(_:forKey:) setInteger(_:forKey:) setObject(_:forKey:) setDouble(_:forKey:) setURL(_:forKey:) Swift 3 In Swift 3 the names of function is changed to set insted of set folloed by ...
To get a value in NSUserDefaults you can use the following functions: Swift arrayForKey(_:) boolForKey(_:) dataForKey(_:) dictionaryForKey(_:) floatForKey(_:) integerForKey(_:) objectForKey(_:) stringArrayForKey(_:) stringForKey(_:) doubleForKey(_:) URLForKey(_:) Objective-C -(nullab...
If you're writing a class that manages resources, you need to implement all the special member functions (see Rule of Three/Five/Zero). The most direct approach to writing the copy constructor and assignment operator would be: person(const person &other) : name(new char[std::strlen(other.n...
One of the most useful queries for end users of large RDBMS's is a search of an information schema. Such a query allows users to rapidly find database tables containing columns of interest, such as when attempting to relate data from 2 tables indirectly through a third table, without existing knowl...
REM This is a comment REM is the official comment command.
::This is a label that acts as a comment The double-colon :: comment shown above is not documented as being a comment command, but it is a special case of a label that acts as a comment. Caution: when labels are used as comments within a bracketed code block or for command, the command processor...

Page 410 of 1336