define paths

pull/43/head
Alexander Bentkamp 2 years ago
parent 375fffcff7
commit 91d41cdd6d

@ -70,10 +70,25 @@ elab "Conclusion" t:str : command => do
elab "PrintCurLevel" : command => do
logInfo (repr (← getCurLevel))
#check Syntax.SepArray
-- /-- Print levels for debugging purposes. -/
elab "PrintLevels" : command => do
logInfo $ repr $ (← getCurWorld).levels.toArray
def Parser.path := Parser.sepBy1Indent Parser.ident "→"
elab "Path" s:Parser.path : command => do
let mut last : Option Name := none
for stx in s.raw.getArgs.getEvenElems do
let some l := last
| do
last := some stx.getId
continue
modifyCurGame fun game =>
pure {game with worlds := {game.worlds with edges := game.worlds.edges.push (l, stx.getId)}}
last := some stx.getId
end metadata
/-! ## Messages -/

@ -217,7 +217,7 @@ new.fold (fun acc a b =>
else acc.insert a b) old
def GameLevel.merge (old : GameLevel) (new : GameLevel) : GameLevel :=
new
new -- simply override old level
def World.merge (old : World) (new : World) : World :=
{ new with
@ -227,7 +227,12 @@ def Game.merge (old : Game) (new : Game) : Game :=
{ new with
worlds := {
nodes := HashMap.merge old.worlds.nodes new.worlds.nodes World.merge
edges := old.worlds.edges ++ new.worlds.edges
edges := Id.run do
let mut res := old.worlds.edges
for e in new.worlds.edges do
if ¬ res.contains e then
res := res.push e
return res
} }
initialize gameExt : PersistentEnvExtension (Name × Game) (Name × Game) (HashMap Name Game) ←

@ -19,3 +19,6 @@ with a level 1 spell book. Good luck."
Conclusion
"There is nothing else so far. Thanks for rescuing natural numbers!"
Path w1 → w2 → w3
Path w1 → v2 → w3
Loading…
Cancel
Save