Tinkering the memory
50 shades of the memory
I have been writing lots of notes on PROLOG and logical programming and people keep asking me, why I never write about reverse engineering. So I decide to give it a try.
I will start with stuff that I think are important for reverse engineering. It will be a bit different of the approaches I see on online tutorials, so I won’t be mad or sad if this notes are not helpful for you. BUT I will be REALLY happy if someone finds it useful!
Prolog vs Haskell
Choose the language for your problem, not the problem for your language.
Prolog vs Haskell
I have been writing lots of notes on PROLOG and some people asked me: why PROLOG? You can solve this problems in any language! And they are right! :) I also believe that it doesn’t matter which problem you have, you can solve it in any given language.
But there is more. I also believe that it is possible to find the best language for the problem you have. No one should be too attached to any language, as every single one has ups and downs!
So I decided to add here two simple examples of PROLOG code in comparison to Haskell code - both extremely elegant IMO - and I will leave it up to you to check how it would look like in your favorite imperative language :)
PROLOG - Part 8
There is logic behind everything and every rule. We sometimes negate this but every thing and every happening has a logic and reason behind it.
In my last post I wrote about cut, fail and repeat. This time I am going to expand the understanding on internals and data structures.
Terms can be constants, variables or a structure.
- A constant may be an atom or a number - which can be an integer or real number. We defined atom some posts ago. :)
- A variable is a string of letters, digits and / or underscores starting with a upper-case letter or an underscore.
- A structure represents an atomic preposition of predicates. Structures have the form
blub(t1,t2,t3,...,tn) where blub is our atom and t1,t2,…,tn are our parameters. n is also the arity of our term.
Keep in mind: there is no type declaration in PROLOG. The interpreter will figure it out for you. :)