Monday, May 28, 2012

Happiness is good pill

Well I guess that can be name of a food dish in China. Wonder what it translates from...

I've been studying Chinese on the slow. 5+ weeks with 9 hours class a week.

Friday, May 18, 2012

Economics

http://krugman.blogs.nytimes.com/2012/05/17/spending-and-growth/

So Japans economy is growing because they are rebuilding their country. So their economy has "positive growth". Counties restraining themselves have negative growth.

Yes! So what? Seems economist always thinks spending more money its better. Is it? Well to grow there economy yes. But does it really mean the country and its citizens are getting richer, which seems to be the underlying assumption? Probably not... That would mean that collective wealth could be created by hmmm. Demolishing your own cities... Hmmm.

I think it's rather that some few people are reaping a lot of money and others are borrowing. Unless the government is printing money, which probably could be justified in this kind of case...

Wednesday, May 9, 2012

forth: max

Hmmm, in implementing MAX in forth returning the biggest of two number from the stack, there might be several solutions. The simplest and most straightforward is something like:

: max over over < if swap else then drop ;


Not using any type of if/branching/skip instruction it becomes more interesting. Using abs is one possibility http://www.retroprogramming.com/2009/06/implement-min-in-forth-without.html but abs is implemented often by branching (?) and isn't a very primitive first forth word. Instead one can use the fact that conditional less than "<" return 0 if false and -1 otherwise...

Using only simple operators I came up with this, it's kind of overly long but...

: max over over < dup 1 + rot rot * negate rot rot * + ;

3 4 max .
-> 4
4 3 max .
-> 4

I guess one could use < to implement abs similarly and use the simplier definition in the link above, but abs becomes:

: abs dup 0 < 2 * 1 + * ; 

77 3 - abs .
-> 74
3 77 - abs .
-> 74

ok, so then using this abs which isn't too fanicful define min instead (max require an swap somewhere)

: min over over - abs - + 2 / ;

3 4 min .
-> 3
4 3 min .
-> 3

--
.sigh