Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- same_Diagonal([[0,11,54,45],[16,1,6,9],[35,7,1,5],[27,3,9,1]])[0,11,54,45]
- [16,1,6,9]
- [35,7,1,5]
- [27,3,9,1]
- [1,6,9]
- [7,1,5]
- [3,9,1]
- [1,5]
- [9,1]
- withoutHead([[0,11,54,45],[16,1,6,9],[35,7,1,5],[27,3,9,1]],X).
- X = [[1, 6, 9], [7, 1, 5], [3, 9, 1]].
- % withoutHead(+ ListOfList, -ListOfList)
- % parameter1: the ListOfList is input
- % parameter2: the ListOfList process output
- withoutHead([HeadRow|TailRow],Squares):-
- maplist(removeHead,TailRow,Squares).
- % removeHead(+List, -List)
- % parameter1: the List is each row
- % parameter2: the List is tail of each row
- removeHead([Head|Tail], Tail).
- same_Diagonal([HeadRow|TailRow]):-
- withoutHead([HeadRow|TailRow],[[Diagonal|Tail]|Back]),
- same_Diagonal(Back).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement