Code: Select all
(defstruct station name)
(defstruct line name stations)
(defstruct karte linien)
(defstruct point station line)
(defstruct route points)
Code: Select all
(setq Oranienburg (make-station :name "Oranienburg"))
(setq Lehnitz (make-station :name "Lehnitz"))
(setq Borgsdorf (make-station :name "Borgsdorf"))
(setq Birkenwerder (make-station :name "Birkenwerder"))
(setq HohenNeuendorf (make-station :name "Hohen Neuendorf"))
(setq Frohnau (make-station :name "Frohnau"))
(setq Hermsdorf (make-station :name "Hermsdorf"))
[...]
Code: Select all
(setq a (list Gesundbrunnen Wedding BeusselStr
Westhafen Jungfernheide Westend
MesseNordICC Westkreuz Halensee
Hohenzollemdamm HeidelbergerPlatz
Bundesplatz Schoneberg Sudkreuz
Tempelhof Hermannstr Neukolln Sonnenallee
TreptowerPark Ostkreuz FrankfurterAllee
StorkowerStr LandsbergerAllee GreifswalderStr
PrenzlauerAllee ShonhauserAllee)
)
(setq b (nconc a a))
(setf S41 (make-line :name "S41" :stations b))
(setq S42 (make-line :name "S42" :stations b))
As you see, both S41 and S42 are circular lines, so I'm creating them as shown above. If i switch to:
Code: Select all
(setf S41 (make-line :name "S41" :stations (nconc a a)))
And my second question:
In order to find reachable stations, I have to loop throught every line in the map, and then look for the current station within them using member as follows:
I'm currently just printing the station and line when found
Code: Select all
(defun nextpoint (apoint)
(dolist (aline (karte-linien mapa))
;; Si la estación de la situación actual está en la lÃnea
(if (member (point-station apoint) (line-stations aline))
;; Su predecesor y sucesor están entre los alcanzables
(printpoint apoint)
)
)
)