CSC 366 Standard Demo Page

The following text was written to the standard output stream when the lp.pro program was executed from swi-prolog.

      mcruz@arch-desktop$ swipl     
      Welcome to SWI-Prolog (Version 2.7.16)
      Copyright (c) 1993-1996 University of Amsterdam.
      All rights reserved.
      For help, use ?- help(Topic). or ?- apropos(Word).
      
      ?- consult('lp.pro'). 
      true.
      
      ?- write_list([1,6,11,2,6,17,43,9]).
      1
      6
      11
      2
      6
      17
      43
      9
      true.
      
      ?- write_list_reversed([1,6,11,2,6,17,43,9]).
      9
      43
      17
      6
      2
      11
      6
      1
      true.
      
      ?- first([1,6,11,2,6,17,43,9],First).
      First = 1.
      
      ?- rest([1,6,11,2,6,17,43,9],Rest).
      Rest = [6, 11, 2, 6, 17, 43, 9].
      
      ?- last([2],Last).
      Last = 2 ;
      false.
      
      ?- last([1,6,11,2,6,17,43,9], Last).
      Last = 9 ;
      false.
      
      ?- nth(0,[1,6,11,2,6,17,43,9],Nth). 
      Nth = 1 ;
      false.
      
      ?- nth(6,[1,6,11,2,6,17,43,9],Nth).
      Nth = 43 ;
      false.
      
      ?- item(6,[1,6,11,2,6,17,43,9],Item).
      Item = 43 ;
      false.
      
      ?- item(0,[1,6,11,2,6,17,43,9],Item).
      Item = 1 ;
      false.
      
      ?- member(Element,[1,6,11,2,6,17,43,9]).
      Element = 1 ;
      Element = 6 ;
      Element = 11 ;
      Element = 2 ;
      Element = 6 ;
      Element = 17 ;
      Element = 43 ;
      Element = 9 ;
      false.
      
      ?- member(17,[1,6,11,2,6,17,43,9]).
      true ;
      false.
      
      ?- count(1,[1,6,11,2,6,17,43,9],Count).
      Count = 1 ;
      Count = 0 ;
      false.
      
      ?- count(6,[1,6,11,2,6,17,43,9],Count).
      Count = 2 ;
      Count = 1 ;
      Count = 1 ;
      Count = 0 ;
      false.
      
      ?- append([1,2,3,4,5],[1,6,11,2,6,17,43,9],Result).
      Result = [1, 2, 3, 4, 5, 1, 6, 11, 2|...].
      
      ?- remove(6,[1,6,11,2,6,17,43,9],Result).
      Result = [1, 11, 2, 6, 17, 43, 9] ;
      false.
      
      ?- remove(6,[],Result).
      Result = [] ;
      false.
      
      ?- remove(6,[5],Result).
      Result = [5] .
      
      ?- remove(6,[6],Result).
      Result = [] ;
      false.
      
      ?- replace(3,20,[1,2,3,4,5,6,7,8,9,10],NewList).
      NewList = [1,2,3,20,5,6,7,8,9,10] ;
      false.
      
      ?- replace(0,100,[1,2,3,4,5,6,7,8,9,10],NewList).
      NewList = [100,2,3,4,5,6,7,8,9,10] ;
      false.
      
      ?- make_list(9,2,List).
      List = [2,2,2,2,2,2,2,2,2] .
      
      ?- make_list(20,[1,2],List).
      List = [[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]] .
      
      ?- reverse([1,2,3,4,5],List).
      List = [5,4,3,2,1] ;
      false.
      
      ?- reverse([],List).
      List = [].
      
      ?- add_first(3,[1,2,3,4,5],Result).
      Result = [3,1,2,3,4,5] ;
      false.
      
      ?- add_last((3,[1,2,3,4,5],Result).
      Result = [1,2,3,4,5,3] ;
      false.
      
      ?- pick([1,2,3,4,5],Item).
      Item = 1 ;
      false.
      
      ?- pick([1,2,3,4,5],Item).
      Item = 2 ;
      false.
      
      ?- pick([1,2,3,4,5],Item).
      Item = 1 ;
      false.
      
      ?- pick([1,2,3,4,5],Item).
      Item = 4 ;
      false.
      
      ?- pick([1,2,3,4,5],Item).
      Item = 2 ;
      false.
      
      ?- take([1,2,3,4,5],X,NewList).
      X = 4,
      NewList = [1,2,3,5] ;
      false.
      
      ?- take([1,2,3,4,5],X,NewList).
      X = 2,
      NewList = [1,3,4,5] ;
      false.
      
      ?- iota(3,List).
      List = [1,2,3] .
      
      ?- iota(20,List).
      List = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] .
      
      ?- sum([1,2,3,4,5,6,7,8,9,10],Sum).
      Sum = 55.
      
      ?- product([1,2,3,4,5,6,7,8,9,10],Product).
      Product = 3628800.
      
      ?- factorial(5,F).
      F = 120 .
      
      ?- min([4,3,5,12,5,2,3,54],Min).
      Min = 2 ; 
      false.
      
      ?- max([4,3,5,12,5,2,3,54],Max).
      Max = 54 ;
      false.
      
      ?- sort_inc([4,3,5,12,5,2,3,54],Sorted).
      Sorted = [2,3,3,4,5,5,12,54] .
      
      ?- sort_dec([4,3,5,12,5,2,3,54],Sorted).
      Sorted = [54,12,5,5,4,3,3,2] .
      
      ?- alist([a,b,c,d],[1,2,3,4],A_List).
      A_List = [pair(a,1),pair(b,2),pair(c,3),pair(d,4)] ;
      false.
      
      ?- assoc([pair(a,1),pair(b,2),pair(c,3),pair(d,4)],c,Value).
      Value = 3 ;
      false.
      
      ?- freq_count([a,b,a,b,c,a,b,c,d,a,b,c,d,e],FCL).
      FCL = [pair(a,4),pair(b,4),pair(c,3),pair(d,2),pair(e,1)] .
      
      ?- make_set([a,b,c,d,e,f],Set).
      Set = [a,b,c,d,e,f].
      
      ?- make_set([a,b,c,w,w,q,s],Set).
      Set = [a,b,c,w,q,s] ;
      Set = [a,b,c,w,w,q,s].
      
      ?- make_set([a,a,b,c,w,w,q,s],Set).
      Set = [a,b,c,w,q,s] ;
      Set = [a,b,c,w,w,q,s] ;
      Set = [a,a,b,c,w,q,s] ;
      Set = [a,a,b,c,w,w,q,s].
      
      ?- flatten([[a,b,c],w,[],[w,q,s]],Flattened).
      Flattened = [a,b,c,w,w,q,s] .
      
      ?- flatten([[a,b,c],d],Flattened).
      Flattened = [a,b,c,d] ;
      false.
      
      ?- flatten([a,b,c,d],Flattened).
      Flattened = [a,b,c,d] ;
      false.