Algorithm transformation
- From: "tmp123" <tmp123@xxxxxxxxx>
- Date: 7 Jan 2006 04:05:37 -0800
Hello,
I'm wondering if there a methodological way to solve the following kind
of problems. I'm going to give an example:
The start could be the set of logical rules that defines whatis/how to
add an integer in a list and the rules to decide if a list is sorted
(sorry if the syntax is prolog like, but it is the programming language
I use usually):
#addition in a list
add(Q,I,[I|Q]).
add([H|Q],I,[H|QR]) <- add(Q,I,QR).
#check is a sorted list
sorted([]).
sorted([_]).
sorted([A,B,|Q]) <- A <= B && sorted([B|Q]).
And the target is to obtain the set of rules for the addition of one
element in a sorted list. That is, the rules of a "sorted_add" that
match the following condition:
sorted_add(A,B,C) <- add(A,B,C) && sorted(C), with precondition
sorted(A).
The rules must match some quality criterias. An example of correct
answer is:
sorted_add([],I,[I]).
sorted_add([H|Q],I,[I,H|Q]) <- I <= H.
sorted_add([H|Q],I,[H|QR]) <- I >= H && sorted_add(Q,I,QR).
Please, has someone references about? Probably is something well known,
but it is far from my usual working area.
Kind regards.
.
- Follow-Ups:
- Re: Algorithm transformation
- From: Jym
- Re: Algorithm transformation
- Prev by Date: CFP: Special Issue on Bioinformatics (The journal Engineering Letters)
- Next by Date: Re: Need help with terminology
- Previous by thread: CFP: Special Issue on Bioinformatics (The journal Engineering Letters)
- Next by thread: Re: Algorithm transformation
- Index(es):
Relevant Pages
|
Loading