Answers for "translate( 1 2 9 one two nine ) prolog programming"

0

translate( 1 2 9 one two nine ) prolog programming

totext(0, 'zero').
totext(1, 'one').
totext(2, 'two').
totext(3, 'three').
totext(4, 'four').
totext(5, 'five').
totext(6, 'six').
totext(7, 'seven').
totext(8, 'eight').
totext(9, 'nine').

translate([], []).
translate([Head|Rest], [TranslatedHead|TranslatedRest]) :-
   totext(Head, TranslatedHead),
   translate(Rest, TranslatedRest).
Posted by: Guest on February-19-2020
0

translate( 1 2 9 one two nine ) prolog programming

domains

    list1=integer*
    list2=symbol*


predicates

    translate(list1,list2)
    means(integer,symbol)


clauses

    translate([],[]).

    translate([],_):-
        write(\"\\nError in Input\").

    translate(_,[]):-
        write(\"\\nError in Input\").

    translate([Head1|Tail1],[Head2|Tail2]):-
        write(Head2,\" = \"),
        means(Head1,Name),
        write(Name,\"\\n\"),
        translate(Tail1,Tail2).


    means(0,zero).

    means(1,one).

    means(2,two).

    means(3,three).

    means(4,four).

    means(5,five).

    means(6,six).

    means(7,seven).

    means(8,eight).

    means(9,nine).


OUT PUT
=======

Goal: translate([1,2,3],[a,b,c])

a = one
b = two
c = three

Yes

-------------------------------------

Goal: translate([1,2,3,4,5,6,7,8,9],[a,b,c,d,e,f,g,h,i])

a = one
b = two
c = three
d = four
e = five
f = six
g = seven
h = eight
i = nine

Yes
Posted by: Guest on February-19-2020

Browse Popular Code Answers by Language