-----
isHidden: true
menupriority: 1
kind: article
created_at: 2010-05-24T20:05:14+02:00
fr: title: Arbres ; Pragmatisme et Formalisme
fr: subtitle: Quand la théorie est plus pratique que la pratique
en: title: Trees; Pragmatism and Formalism
en: subtitle: When theory is more efficient than practice
author_name: Yann Esposito
author_uri: yannesposito.com
tags:
en: - tree
en: - theory
en: - mathematics
fr: - arbre
fr: - théorie
fr: - mathématiques
-----
begindiv(intro)
TL;DR:
- I tried to program a simple filter
- Was blocked 2 days
- Then stopped working like an engineer monkey
- Used a pen and a sheet of paper.
- Made some math.
- Crushed the problem in 10 minutes
- Conclusion: The pragmatism shouldn't mean "never use theory".
enddiv
## Abstract (longer than TL;DR:)
For my job, I needed to resolve a problem. It first seems not too hard.
Then I started working directly on my program.
I entered in a try & repair loop.
Unfortunately, I stay blocked in that loop for 2 days.
At each turn, I believed I was almost at the solution.
And this is why, I just said:
> Just a simple thing to repair and that should be done.
Unfortunately
newcorps
en: # First: my experience
fr: # L'anecdote
Apparently 90% of programmer are unable to program a binary search without bug.
The algorithm is well known and easy to understand.
However it is difficult to program it without any flaw.
I participated to [this contest](http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/).
And you can see the [results here](http://reprog.wordpress.com/2010/04/21/binary-search-redux-part-1/)[^1].
I had to face a problem of the same kind at my job. The problem was simple to the start. Simply transform an
And the destination format was in the following general format:
At first sight I believed it will be easy. I was so certain it will be easy that I fixed to myself the following rules:
1. do not use
s/something/something else/g
It is not only possible but I believe it is the best way of doing this.
# Solution
Transform this tree:
R - C - tag1 \ \ tag2 \ E - R - C - tag1 \ \ \ tag2 \ E ... R - C - tag1 \ \ tag2 E ...to this tree:
tag1 / M - V - M - V - tag2 tag1 \ / M -- V - tag2 \ \ \ M \ tag1 \ / V - tag2 \ Musing only an acyclic deterministic tree transducer: > C -> \varepsilon > E -> R > R -> V That is all. # conclusion It should seems a bit paradoxal, but sometimes the most pragmatic approach to a pragmatic problem is to use the theoretical methodology. Not the commonly accepted pragmatic one. This simple experience prove this point.