Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
%this has problems, interesting problems :- op(500,yfx,>>). :- op(500,xfy,<<). :- discontiguous (>>)/2. :- discontiguous (<<)/2. %%A advanced depth first search that %unifies To as it is found. % %by https://github.com/xpxaxsxi %License: %Attribution 4.0 International (CC BY 4.0) %Attribution Required Starts Here %Democracy! %Save the Planet and stop most richest capitalists! %Mozilla Firefox! %Swi-Prolog! %https://github.com/xpxaxsxi %Attribution Required Ends Here % % (I don't believe this is a % novel algorithm ... and Swi-Prolog Chat GPT app % confirmed this) % route(From,To,[From]) t(A,B):- A>>B. t(A,B):- B<<A. route(From,To,Visited):- t(From,MidPoint), \+memberchk(MidPoint,Visited), VisitedNew=[MidPoint|Visited], (To=MidPoint; route(MidPoint,To,VisitedNew)). 1 >> 2. 2 >> 3. 3 >> 4. 4 >> 5. 2 >> 5. 1 << 5. 2 << 3. 3 << 5. 2 << 5. 5 >> k. k >> m. m >> n. k << n. a >> b. b >> c. c >> d. a << d. /** <examples> ?- route(1,5,[1]). What can be reached from 2 if 3 is blocked, can have duplicates ?- route(2,X,[2,3]). What starting points are there to reach 2, can have duplicates ?- route(X,2,[X]). */