Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript Boolean

Name: Anonymous 2016-09-30 21:51

The Boolean object is an object wrapper for a boolean value.

Syntax

new Boolean([value])

Parameters

value
Optional. The initial value of the Boolean object.

Any object whose value is not undefined or null, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement. For example, the condition in the following if statement evaluates to true:

var x = new Boolean("false");
if (x) {
// this code is executed
}


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean

Name: Cudder !cXCudderUE 2016-10-08 16:16

>>25
ENTERPRISE QUALITY SCALABLE TURNKEY null SOLUTIONS

Since the child nodes may not exist, one must modify the procedure by adding non-existence or null checks[...]This however makes the procedure more complicated
What a strawman. They deliberately overcomplicate the function just so they can "simplify" it with some OOP bullshit.

This separates normal logic from special case handling, and makes the code easier to understand
Bullshit. It doesn't make the code "easier to understand" if you have to find where the hell that "special case" (which isn't really special, it's just the base case of the recursion) got separated out to.

int tree_size(struct treenode *n) {
return n ? 1 + tree_size(n->left) + tree_size(n->right) : 0;
}


Amusingly enough, counting the number of nodes in a binary tree is only 13 lines of x86 Asm and less than 30 bytes.

tree_size:
test eax, eax
jz tree_size_ret
push eax
mov eax, [eax+tree.left]
call tree_size
mov ecx, eax
pop eax
mov eax, [eax+tree.right]
call tree_size
lea eax, [eax+ecx+1]
tree_size_ret:
ret


>>27
Also bullshit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List