1 Replies - 1318 Views - Last Post: 03 November 2009 - 01:11 PM

#1 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 729
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

insertion sort of a list (PROLOG)

Posted 20 April 2009 - 07:09 PM

Description: the predicate insertionsort returns true if R is the sorted list of [H|T]
inserting_in_place(X, [], [X]).

inserting_in_place(X, [H|T], [X|L]):-
	X =< H, inserting_in_place(H, T, L).

inserting_in_place(X, [H|T], [H|L]):-
	X > H, inserting_in_place(X, T, L).

insertionsort([], []).

insertionsort([H|T], R):-
	insertionsort(T, W), inserting_in_place(H, W, R).


Is This A Good Question/Topic? 0
  • +

Replies To: insertion sort of a list (PROLOG)

#2 emrah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 03-November 09

Re: insertion sort of a list (PROLOG)

Posted 03 November 2009 - 01:11 PM

hi thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1