Tutorial by Examples: c

A closure is a procedure that holds internal state: Define a procedure that returns a closure The procedure make-an-adder takes one argument x and returns a function that closes over the value. Or to put it another way, x is within the lexical scope of the returned function. #lang racket (define...
Let me start by saying you should first visit Beej's Guide to Network Programming and give it a quick read, which explains most of this stuff a bit more verbosely. We'll be creating a simple TCP server here which will say "Hello World" to all incoming connections and then close them. Anoth...
This program is complimentary to Hello TCP Server program, you can run either of them to check the validity of each other. The program flow is quite common with Hello TCP server, so make sure to take a look at that too. Here's the code - #include <cstring> #include <iostream> #includ...
Have you ever wondered how the search engines work? How does Google line-up millions of results in front of you in just a few milliseconds? How does a huge database situated thousands of miles away from you find out information you're searching for and send them back to you? The reason behind this i...
Often one wants to intermittently run one or more validation batches during the course of training a deep network. Typically the training data are fed by a queue while the validation data might be passed through the feed_dict parameter in sess.run(). tf.placeholder_with_default() is designed to work...
01 fillertest. 03 fillertest-1 PIC 9(10) value 2222222222. 03 filler PIC X value '|'. 03 fillertest-2 PIC X(10) value all 'A'. 03 filler PIC 9(03) value 111. 03 filler PIC X value '.'. INITIALIZE fillertest INITIALIZE fillertest REPLACING NUM...
One of the most important implementations of Dynamic Programming is finding out the Longest Common Subsequence. Let's define some of the basic terminologies first. Subsequence: A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the orde...
GCobol identification division. program-id. inspecting. data division. working-storage section. 01 ORIGINAL pic XXXX/XX/XXBXX/XX/XXXXXXX/XX. 01 DATEREC pic XXXX/XX/XXBXX/XX/XXXXXXX/XX. procedure division. move fun...
You can do neat things via the results of Array "comprehensions"... Like assign multiple variables... from the result of a looping for statement... [express,_] = (require x for x in ['express','underscore']) Or a syntactically sweet version of a "mapped" function call, etc.....
Regular expression support for tust is provided by the regex crate, add it to your Cargo.toml: [dependencies] regex = "0.1" The main interface of the regex crate is regex::Regex: extern crate regex; use regex::Regex; fn main() { //"r" stands for "raw" str...
extern crate regex; use regex::Regex; fn main() { let rg = Regex::new(r"was (\d+)").unwrap(); // Regex::captures returns Option<Captures>, // first element is the full match and others // are capture groups match rg.captures("The year was 2016")...
extern crate regex; use regex::Regex; fn main() { let rg = Regex::new(r"(\d+)").unwrap(); // Regex::replace replaces first match // from it's first argument with the second argument // => Some string with numbers (not really) rg.replace("Some string ...
If you want to perform a user input validation of your textfield use the following code snippet: // MARK: - UITextFieldDelegate let allowedCharacters = CharacterSet(charactersIn:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz").inverted func textField(_ textField:...
A common approach to get the top most UIViewController is to get the RootViewController of your active UIWindow. I wrote an extension for this: extension UIApplication { func topViewController(_ base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController ...
Using the NotificationCenter of iOS, which can be very powerful, you are able to intercept certain app-wide events: NotificationCenter.default.addObserver( self, selector: #selector(ViewController.do(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, o...
Before reading this example, it is required to have a brief idea on edge-relaxation. You can learn it from here Bellman-Ford Algorithm is computes the shortest paths from a single source vertex to all of the other vertices in a weighted digraph. Even though it is slower than Dijkstra's Algorithm, i...
In case of problems, enable the internal logger <nlog internalLogFile="c:\log.txt" internalLogLevel="Trace"> <targets> <!-- target configuration here --> </targets> <rules> <!-- log routing rules --> </rules&gt...
In case of problems, enable the internal logger. C# example: // set internal log level InternalLogger.LogLevel = LogLevel.Trace; // enable one of the targets: file, console, logwriter: // enable internal logging to a file (absolute or relative path. Don't use layout renderers) InternalL...
using NLog; using NLog.Config; using NLog.Targets; namespace MyNamespace { [Target("MyFirst")] public sealed class MyFirstTarget: TargetWithLayout //or inherit from Target { public MyFirstTarget() { //set defaults ...

Page 599 of 826