TweedHeads's comments

TweedHeads | 16 years ago | on: Y Combinators in C#

Full anonimity, thanks to tilly (separated for better understanding):

  builder   = function(x){ return function(n){ return x(x)(n); }}
  factorial = function(f){ return function(n){ return n==0?1:n*f(f)(n-1);} }
  alert(builder(factorial)(8))
One liner, just seed factorial to builder:

  r = (function(x){ return function(n){ return x(x)(n); } } (function(f){ return function(n){ return n==0?1:n*f(f)(n-1);} }))(8);

TweedHeads | 16 years ago | on: Y Combinators in C#

Javascript can do it all:

  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 4320

TweedHeads | 16 years ago | on: Nokia Plans to Start Making Netbooks

"Its first netbook, the Nokia Booklet 3G, will use Microsoft’s Windows software and Intel’s Atom processor"

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: Revenge of the Nerds

Taking a closer look at my macbook keyboard, of all the lisp forks, I'd go with squared brackets [lisp] for convenience.

Ergonomics win.

TweedHeads | 16 years ago | on: Revenge of the Nerds

Dear Paul, when I say its syntax is its best friend, that's exactly what I'm talking about.

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

(defun foo (n) (lambda (i) (incf n i)))

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

"how many fingers do I have? 5 - 1 = 4. Oops."

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

Don't try your cheap tricks on me.

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

"I am starting to think Dijkstra is about the worst thing ever happening to software development."

"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

No, your language limitations don't have to force the rest of the world to accept them.

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: Dijkstra: Why numbering should start at zero

"We could still achieve the same effect if we started indexing at 1, but it would require more code, and it would be less clear."

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

"keeping the lower bound within the natural numbers; having the upper bound be the number of elements in the preceding sequence, etc."

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

Look at your hand and start counting your fingers while naming them:

[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

I don't care if computers think in 0s and 1s or if arrays should start at 0 because it is the way computers think.

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: Benefits of Rising Early, and How to Do It

When I was younger I used to wake up at 4pm and code till early 6am, pure zen.

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.

page 1