Help talk:Request a new programming language: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
(Moved programming example.)
Line 2: Line 2:
I would like to see Prolog as a language of rosettacode so if it goes in, i'll give some example such as making a hash with two arrays
I would like to see Prolog as a language of rosettacode so if it goes in, i'll give some example such as making a hash with two arrays
(it's in swi-prolog, for sicstus include list module)
(it's in swi-prolog, for sicstus include list module)
: I moved the programming example to [[Creating a Hash from Two Arrays]]. --[[User:Short Circuit|Short Circuit]] 14:36, 11 November 2007 (MST)


% this one with side effect hash table creation

:-dynamic hash/2.

make_hash([],[]).
make_hash([H|Q],[H1|Q1]):-
assert(hash(H,H1)),
make_hash(Q,Q1).

:-make_hash([un,deux,trois],[[a,b,c],[d,e,f],[g,h,i]])


% this one without side effects

make_hash_pure([],[],[]).
make_hash_pure([H|Q],[H1|Q1],[hash(H,H1)|R]):-
make_hash_pure(Q,Q1,R).

:-make_hash_pure([un,deux,trois],[[a,b,c],[d,e,f],[g,h,i]],L),findall(M,(member(M,L),assert(M)),L).

Revision as of 21:36, 11 November 2007

Hello, I would like to see Prolog as a language of rosettacode so if it goes in, i'll give some example such as making a hash with two arrays (it's in swi-prolog, for sicstus include list module)

I moved the programming example to Creating a Hash from Two Arrays. --Short Circuit 14:36, 11 November 2007 (MST)