Comment

Comment by tinco

That was awesome, thanks for explaining that for us. It makes a lot of sense the way you explain it, and I quickly got the idea that you can make some powerful expressions this way.

The smooth creation of lists is I think one of the most important language features higher level languages have over lower level languages like C.

Just this thing:

    c::a$"\n"
That's all I needed to be convinced that modern languages should have similar view constructs. In ruby it'd be:

  c = a.map.with_index{|a,i| a == "\n" ? i : nil }.reject{|i| i.nil? }
Quite a mouthful, mainly because Ruby lacks a neat way to do '$'. But doing the same thing in C would really be awkward, and likely not as efficient unless you have some fancy code for building enumerators in C.
parent tinco 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton