Prolog: create new list structure of known list -


i trying take 1 list , create new 1 structure.


the first list have this:

list 1 out of x: [[4,2,5,1,1,7,4], [1,0,2,1,5,4,4], [2,8,0,2,2,6,2], [8,9,2,0,1,6,2], [6,2,0,3,0,2,2], [3,6,6,3,0,2,9], [6,2,1,4,3,3,9]] 

the code have @ moment this:

onemap(v,[_,_,v]). listmap([],[]). listmap([h|t],[h1|t1]):- listmap(t,t1),onemap(h,h1). 

the problem here each line in list inside new list, instead want value inside line.

part of output @ moment:

[[_g21217,_g21220,[4,2,5,1,1,7,4]],[_g21202,_g21205,[1,0,2,1,5,4,4]],... 

looking this:

[[_g21217,_g21220,4],[_g21202,_g21205,2],[_g21202,_g21205,5],... 

the solution:

okay have after time found helped me double list problem:

onemap(v,[_,_,v]).   listmap1([],[]). listmap2([],[]).  listmap1([h|t],[h1|t1]):- listmap1(t,t1),listmap2(h,h1).  listmap2([h|t],[h1|t1]):- listmap2(t,t1), onemap(v,h1). 

if have smarter solution hear it.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -