% Author:
% Date: 5/30/2014

% number 7
run:- write('Enter two numbers:'),
      read(X),
      read(Y),
      seq(X,Y,L),
      write(L).
seq(X,Y,[]):-
             X>Y.
seq(X,Y,[X|L]):-
                X=<Y,
                X1 is X+1,
                seq(X1,Y,L).

%number 8

classify([]):-!.
classify([H|T]):-
                 my_check(H),
                 classify(T).
my_check(H):-
             atom(H), atom_length(H,L), L=1,
             write(H), write(' is character/atom \n').
my_check(H):-
             atom(H),
             write(H ), write(' is atom\n').
my_check(H):-
             number(H),
             write(H ), write(' is number\n').

my_check(H):-
             is_list(H),
             write(H ), write(' is list\n').
             
% number 9
rep('Y'):-sqr.
sqr:- write('Enter an Integer:'),
      read(X), Y is X*X,
      write(Y),
      write('\n Again:'),
      read(C),
      rep(C).
      
%number 10

occur(C) :-
        open('c:\\a.txt',read, X),
        current_input(Stream), set_input(X),

        count(C,0),

        close(X),
        set_input(Stream).

count(C,N):- get_char(D),comp(C,D,N).

comp(_,end_of_file,N):- write(N),!.
comp(C,D,N):- C=D, N1 is N+1, count(C,N1).
comp(C,D,N):- C\=D, count(C,N).

          

