http://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursive_functions_and_algorithms A common computer programming tactic is to divide a problem into sub-problems of the same type as the original, solve those sub-problems, and combine the res…
在scala中如果一个函数在最后一步调用自己(必须完全调用自己,不能加其他额外运算子),那么在scala中会复用函数栈,这样递归调用就转化成了线性的调用,效率大大的提高.If a function calls itself as its last action, the function's stack frame can be reused. This is called tail recursion.=> Tail recursive functions are iterative proc…
In this article, I'm going to introduce a general pattern named Lazy Iterator for converting recursive traversal to iterator. Let's start with a familiar example of inorder traversal of binary tree. It is straightforward to write a recursive function…
Background C++ is one of the main development languages used by many of Google's open-source projects. As every C++ programmer knows, the language has many powerful features, but this power brings with it complexity, which in turn can make code more…
Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose Ends Program Structure Names Declarations Variables Assignments Type Declarations Packages and Files Scope Basic Data Types Integers Floating-Point Numbe…
Google C++ Style Guide Table of Contents Header Files Self-contained Headers The #define Guard Forward Declarations Inline Functions Names and Order of Includes Scoping Namespaces Unnamed Namespaces and Static Variables Nonmember, Static Member, an…
Python算法:推导.递归和规约 注:本节中我给定下面三个重要词汇的中文翻译分别是:Induction(推导).Recursion(递归)和Reduction(规约) 本节主要介绍算法设计的三个核心知识:Induction(推导).Recursion(递归)和Reduction(规约),这是原书的重点和难点部分 正如标题所示,本节主要介绍下面三部分内容: • Reduction means transforming one problem to another. We normally red…
Memory Layout of C Programs A typical memory representation of C program consists of following sections. 1. Text segment2. Initialized data segment3. Uninitialized data segment4. Stack5. Heap A typical memory layout of a running process 1. Text Seg…
Given the expansive growth in the field, it's become challenging to discern what belongs in a modern computer science degree. My own faculty is engaging in this debate, so I've coalesced my thoughts as an answer to the question, "What should every co…
1. Functional programming treats computation as the evaluation of mathematical and avoids state and mutable data. Scala encourages an expression-oriented programming(EOP) 1) In expression-oriented programming every statement is an expression. A state…
Lisp The roots of lisp Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I Django Django Official Tutorial How to create a basic blog in Django Tango with Django Pwn~ How to become a hacker Python Python Official Docs…
This document lists some basic differences between Nemerle and C# in a terse form. If you know Java or C++ it should still be fairly helpful. Changes In Expressions C# Nemerle Remarks const int x = 3; const string y = "foo"; readonly Object obj…
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] Summary: recursive functions class Solution { public: vector<vect…
Why, every fault’s condemn’d ere it be done:Mine were the very cipher of a function. . .—William Shakespeare, Measure for Measure The best thing about JavaScript is its implementation of functions. It got almost everything right. But, as you should e…
OK, let's continue. Conditional Judgments and Loop if if-else if-elif-else while for break continue multiple loop Differences between Dict and Set Dict: A kind of structure in the type of "Key-Value" described in "{}" formed by "k…