Skip to content
Snippets Groups Projects
Select Git revision
  • 379098f0e172c4aa9a373ac6e249b7e63a6aac52
  • master default
  • dependabot/nuget/source/Sample/Newtonsoft.Json-13.0.1
  • dependabot/nuget/source/MasterDevs.ChromeDevTools.Tests/Newtonsoft.Json-13.0.1
  • dependabot/nuget/source/ProtocolGenerator/Newtonsoft.Json-13.0.1
  • dependabot/nuget/source/ChromeDevTools/Newtonsoft.Json-13.0.1
  • dependabot/nuget/source/ChromeDevTools/System.Net.Http-4.3.4
  • revert-29-revert-24-protocol_62
  • revert-24-protocol_62
  • 1.1.0
  • 1.0.2
  • 1.0.1
  • 1.0.0.40915
13 results

SearchInResourceCommandResponse.cs

Blame
  • 2019-10-31-tutorial.pl 1.20 KiB
    % INTRODUCTION
    
    animal(elephant).
    
    bigger(elephant, bird).
    bigger(elephant, cow).
    bigger(cow, mouse).
    
    bigger(X, Y) :-
        bigger(X, A), bigger(A, Y).
    
    % Note: The above definition for a transitive relation
    % results in loop, which wasn't resolved during the tutorial.
    % If you want to know more about it, take a look at this answer:
    % https://stackoverflow.com/a/28615704
    
    
    % SIMPLE LIST TASKS
    % inspired from http://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/
    
    getfirst([X|_], X).
    
    getlast([X], X).
    getlast([_|R], X) :-
        getlast(R, X).
    
    getsecondlast([X,_], X).
    getsecondlast([_|R], X) :-
        getsecondlast(R, X).
    
    getlength([], 0).
    getlength([X|R], L) :-
        getlength(R, N), L is N+1.
    
    second([], []).
    second([X], [X]).
    second([X,Y|R], [X|S]) :-
        second(R, S).
    
    fourth(X, Y) :-
        second(X, Z), second(Z, Y).
    
    prepend(X,SomeList,[X|SomeList]).
    
    duplicate([], []).
    duplicate([X|R], [X,X|S]) :-
        duplicate(R, S).
    
    
    % INSERTION SORT
    
    insert(X, [], [X]).
    insert(X, [H|R], [H|S]) :-
        X >= H, insert(X, R, S).
    insert(X, [H|R], [X,H|R]) :-
        X =< H.
    
    inssort([], []).
    inssort([H|T], L) :-
        inssort(T, TSorted),
        write('inserting '),
        write(H),
        write('\n'),
        insert(H, TSorted, L).