TweedHeads | 16 years ago | on: Y Combinators in C#
TweedHeads's comments
TweedHeads | 16 years ago | on: Y Combinators in C#
function fac(x){ return x==0?1:x*fac(x-1); }
a = fac(8);
or a one-liner:
a = (function fac(x){ return x==0?1:x*fac(x-1); })(8);
Both ways spit 4320TweedHeads | 16 years ago | on: Nokia Plans to Start Making Netbooks
There, doomed.
If you don't extend your arms to the open source community, don't expect us to open our arms when you need us.
Fuck you Nokia.
TweedHeads | 16 years ago | on: D. Crockford on JSON: "An influence was Rebol, a shame it’s not more popular"
Then the title is misleading. Rebol as an influence to what?
We should ask that question to Brendan to see what influenced HIM to design javascript as he did.
TweedHeads | 16 years ago | on: D. Crockford on JSON: "An influence was Rebol, a shame it’s not more popular"
Brendan Eich did, JSON is Javascript, part of it, its own data structure, it is javascript object notation.
What Crockford did was to spread its adoption among other languages, building libraries and encouraging people to use them.
To Caesar what is Caesar’s...
TweedHeads | 16 years ago | on: Revenge of the Nerds
Ergonomics win.
TweedHeads | 16 years ago | on: Revenge of the Nerds
Now, say I fork lisp and change one little thing:
(defun foo (n) (lambda (i) (incf n i)))
to this:
[defun foo [n] [lambda [i] [incf n i]]]
or even this:
{defun foo {n} {lambda {i} {incf n i}}}
or how about this?
<defun foo <n> <lambda <i> <incf n i>>>
Hmm, trees are powerful, no matter how they are expressed huh?
What if we can represent the same trees using colons and commas as delimiters?
:defun foo:n, :lambda:i, :incf n i.
Maybe spice it up a bit using periods as recursive closing delimiter.
See? still powerful trees!
Between common lisp and colon lisp, I still use the latter.
Love is blindness.
TweedHeads | 16 years ago | on: Revenge of the Nerds
def foo(n): lambda i: n += i
Give me two powerful languages with the same features and I'll pick the latter for its syntax.
So no, lisp may be the best right now, but it won't be the best forever, its syntax is its best friend and worst enemy.
Something lispers will never understand. Love is blindness.
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
Upper-Lower+1, easy. Whenever the lower is 1, just the upper is enough.
In your case you go from 0 to 4, how's that different from how many fingers you have? 4-0=4 Oops.
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
We go from 1 to 5, so the math would be 5-1 +1
You go from 0 to 4, the math would be the same, 4-0 +1
Using 5 as your upper bound, then starting from 0 to 4 is the same as me using 6 as my upper bound then going from 1 to 5.
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
"0 based for spatial coordinates, 1 based for lists and character positions."
Sums up my thoughts pretty well.
The real reason we do zero-based counting in computers is because of bits, speed and laziness.
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
As I alreay said, some languages use the simpler construct:
For i=1 to N
And C could easily use:
for(i=1;i==n;i++)
just by changing the way the loop condition works.
So as you say, it is all about the language.
TweedHeads | 16 years ago | on: Worrying trends in programming languages: Javascript
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
Really?
How about dealing with strings?
"123456789" how many chars we have? 9
char[1] = 1
char[2] = 2
:
char[9] = 9
Now, let's try the C approach:
"123456789"
char[0] = 1
char[1] = 2
:
char[8] = 9
where is char "1"? at zero index!
how many elements we have?
last index plus one!
see? there is already confusion in place, or as you say, more code and less clear...
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
Read your post and understand the same can be said of using one-based indexing.
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
[1] thumb
[2] index
[3] middle
[4] ring
[5] pinkie
so we have a simple range [1..5]
which can be represented in so many ways in computer programs:
for i=1 to 5 print finger[i]
for(i in [1..5]) print finger[i]
my first finger[1] is my thumb
my last finger[5] is my pinkie
how many fingers we have? as many as the last index in the list: 5
-
now, C programmers like to count this way:
for(i=0;i<5;i++) print finger[i]
where finger[0] is thumb
and finger[4] is pinkie
how many fingers we have?
as many as the last index in the list plus one: 4+1
how human-like!
And that's why you get so messy when trying to get the string position of a substring:
if(pos>-1) exists, since pos=0 means the substring is in the starting position
again, how human-like!
But how dare I argue with C programmers without being burned at the stake?
TweedHeads | 16 years ago | on: Dijkstra: Why numbering should start at zero
Computers were made to serve us and as such they should translate all their inner thoughts to more human consumable data.
Five is 5, not 101.
So no, numbering should start at ONE, even if most programmers have already been hardwired to start counting from zero.
TweedHeads | 16 years ago | on: Video to Appear in Paper Magazines [Worlds First]
TweedHeads | 16 years ago | on: Benefits of Rising Early, and How to Do It
Now that I am older I try to go to bed the same day I wake up.
The older I get the earlier I want to wake up, the less I want to sleep.