News for hackers. Stuff that matters.
Re:The Power of Prolog by benjiweber on Thursday April 06, 2017 @09:52AM (#14050469)
SQL can do recursive rules too. SQL tutorials often do SQL a disservice by introducing it as a database query language rather than relational algebra :)

  example=# select * from move;
    place  | method | newplace 
  ---------+--------+----------
   home    | taxi   | halifax
   halifax | train  | gatwick
   gatwick | plane  | rome
  (3 rows)
  
  example=# create view on_route as with recursive on_route(place, newplace, length, path) as (select place, newplace, 1 as length, place as path FROM move UNION select on_route.place, move.newplace, on_route.length + 1, path || '->' || move.place as path FROM move JOIN on_route ON on_route.newplace = move.place) SELECT place, newplace, length, path || '->' || newplace as path FROM on_route;
  CREATE VIEW
  example=# select distinct true from on_route WHERE place = 'home' and newplace = 'rome';
   bool 
  ------
   t
  (1 row)
  
  example=# select path from on_route WHERE place = 'home' and newplace = 'rome';
               path             
  ------------------------------
   home->halifax->gatwick->rome
Re:The Power of Prolog by tom_mellior on Thursday April 06, 2017 @11:04AM (#14051145)
Ha, excellent :-) I learned something, thanks.

(The greater point still stands, terms and unification and all that.)