Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % This buffer is for notes you don't want to save.
- % If you want to create a file, visit that file with C-x C-f,
- % then enter the text in that file's own buffer.
- %Problem1
- :-op(300, xfx, plays).
- %:-op(200, xfy, and).
- :-op(500,xfx, was).
- :-op(600, xfx, of).
- :-op(400, fx, the).
- %plays(jimmy, and(football, and(basketball, tennis))).
- john was the secretary of the department.
- %was(john, of(the(secretary), the(department))).
- %
- %
- %Problem 2
- :-op(40,fx,deleting).
- :-op(20,xfx, gives).
- :-op(30,xfx, from).
- deleting _ from [] gives [].
- deleting Item from [Item|Tail] gives Result :-
- deleting Item from Tail gives Result.
- deleting Item from [Head|Tail] gives [Head|Result]:-
- Item \= Head,
- deleting Item from Tail gives Result.
- :-op(500, fx, concat).
- :-op(15, yfx, and).
- concat List1 and List2 gives Result :-
- is_list(List1),
- is_list(List2),
- append(List1, List2, Result).
- concat Expr and List gives Result :-
- concat Expr gives L1,
- append(L1, List, Result).
- %Problem 3
- sq(N) :-
- number(N),
- S is N*N,
- writef('%d \n',[S]).
- squares :-
- writef('Give number: '),
- read(Term),
- Term \= stop,
- sq(Term),
- squares.
- %Problem 4
- %
- writelist([]) :- !.
- writelist([H|T]) :-
- write(H),
- write(' '),
- writelist(T).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement