Monday, November 18, 2013

hi in china

so the american at next table had been in beijing.

he said hi to.everyone.
they didnt answer and looked funny at.him.

at least in shanghai they responded he said.
so he concluded they are more friendly here.

hai in chinese could mean ocean, taibted food,
to do.harm, evil, intent, or even.yes depending on
how you say it...


Sent with AquaMail for Android
http://www.aqua-mail.com

Sunday, November 17, 2013

china makes me smile...

the taxi passes a police car driving with flashing lights, were driving 85
the traffic sign says 35. no problem!


Sent with AquaMail for Android
http://www.aqua-mail.com

Wednesday, July 31, 2013

Friday, May 10, 2013

lgtm

Alright, either the miserably weather is over after 2 months rain bit arriving in chengdu warmed me a little. Will see if it's a bigger city than chonhqing in spite of it having fewer people, 10million instead of 32...

Monday, May 6, 2013

Not what you think

These is implements given when eating a sandwich. Chinese, especially more country side will not often eat food holding it directly in their hands. Especially for kfc and western style food places coffee shops where you eat finger food.

I remember when first visiting China and Thomas and Mareen in Beijing many years ago. I met a guy who just arrived in Beijing he was a chef, we ate in his hometown style cheap restaurant in a hutong which now is gone. One time I took him to MacDonalds. He never eaten there. I got some burgers. After we sat down to eat he just looked at me grabbing my burger with my hands and eating. He went and argued with the people behind the counter and came back with a plastic spoon which he used to eat his burger with. In one way I was thinking that, hmmm, the Chinese are rather civilized....

Wednesday, April 24, 2013

Taxi: green light turn right... Becomes straight green light

Taking taxi in China can be quite interesting, its also a good opportunity to practice your bad Chinese, in the end you'll leave and never meet again so it doesn't really become uncomfortable.

Ask where he's from, how old, have wife (taitai), how many taitai... The last question is usually appreciated!

I'm any case, one trick late night with little traffic is that a red light ahead but green light right turn can easily be used to go straight albeit a bit bent. Turn slightly right, veer through the intersection turn right again, which now actually is straightening out veering back, thus two right bridged by a didn't turn right becomes an almost green straight.

Also , they was a police block with alco test which he u-turned in front of because it saves time... The police it would seem doesn't mind these things. And somebody really really drunk wouldn't see them thus will get caught.

It's all in one harmonious day.

Tuesday, March 19, 2013

What is 3+2*2 ?

You might know that 3+2*2 is 7 and not 10. At least for mathematicians.

Now all people aren't mathematicians, and neither are computers as it turn out. Somebody painstakingly told the computer how to do this correctly.

OK

How does this work? Well for anything a computer reads there is a parser that transforms text to another text which is closer to what a computer understands.

Since I lately been telling my computer that it's a Panda I have to talk panda language to it.

In this case you can't say 3+2*2 but have to say
---  plus(3, times(2, 2))

You could say. 2.times(2).plus(3) buy that's another story.

From here on it gets technical, you can skip it if you want, most will. The ones who might understand it may say it's bullocks too! That's fine. Go watch star wars then instead!

- - -

So I was thinking that a parser essentially need backtracking for simplicity of implementation. It also needs a way to choose between alternatives.

Since my language Panda already does backtracking I only need a way to implement choice. In SQL is called OR. I don't have it. Then it struck me that OR is just a kind of enumeration and invocation of different code paths!

I just need a way of listing the appropriate functions that are the choices and then apply them to the given arguments. Turns out I already have this by reflection on functions. That is I can find all functions in my system matching a certain name or parameters, and then call each of those functions.

You can for example say:

   func('number_number_number').call(4,3)

And it will give you 1.3333 4 3 1 7 12
Which are the results of divide, max, min, minus, plus, times.

It's not Beatiful, but it isn't too bad either.

I wrote a simple expression parser, handling priorities of operators correctly.

This is how its used.

'3+2*2'.syntax.expr.empty.gen.panda
This gives 7!

.syntax generates a syntax structure
.expr parses the expression
.empty requires that after parsing the expression the state is empty
.gen returns the generated code as of previously given
.panda takes that code and gives it to panda, that, hmmmm, will parse it, generate internal code, then JavaScript code which then will be run.

Time to sleep.