src/Tools/isac/calcelems.sml
changeset 55450 a7c61c0bd437
parent 55449 b218049a9b4e
child 55451 1395832f4f53
     1.1 --- a/src/Tools/isac/calcelems.sml	Sun Jun 15 18:39:59 2014 +0200
     1.2 +++ b/src/Tools/isac/calcelems.sml	Thu Jun 19 07:40:46 2014 +0200
     1.3 @@ -1035,6 +1035,27 @@
     1.4          in merge_ptyps' th' end;
     1.5  in fold (add_the th) thes end
     1.6  
     1.7 +fun Html_default exist = (Html {guh = theID2guh exist, 
     1.8 +  coursedesign = ["isac team 2006"], mathauthors = [], html = ""})
     1.9 +
    1.10 +fun fill_parents (exist, [i]) thydata = Ptyp (i, [thydata], [])
    1.11 +  | fill_parents (exist, i :: is) thydata =
    1.12 +    Ptyp (i, [Html_default (exist @ [i])], [fill_parents (exist @ [i], is) thydata])
    1.13 +  | fill_parents _ _ = error "Html_default: avoid ML warning: Matches are not exhaustive"
    1.14 +
    1.15 +fun add_thydata (exist, is) thydata [] = [fill_parents (exist, is) thydata]
    1.16 +  | add_thydata (exist, [i]) data (pys as (py as Ptyp (key, _, _)) :: pyss) = 
    1.17 +    if i = key
    1.18 +    then pys (* preserve existing thydata *) 
    1.19 +    else py :: add_thydata (exist, [i]) data pyss
    1.20 +  | add_thydata (exist, iss as (i :: is)) data ((py as Ptyp (key, d, pys)) :: pyss) = 
    1.21 +    if i = key
    1.22 +    then       
    1.23 +      if length pys = 0
    1.24 +      then Ptyp (key, d, [fill_parents (exist @ [i], is) data]) :: pyss
    1.25 +      else Ptyp (key, d, add_thydata (exist @ [i], is) data pys) :: pyss
    1.26 +    else py :: add_thydata (exist, iss) data pyss
    1.27 +  | add_thydata _ _ _ = error "add_thydata: avoid ML warning: Matches are not exhaustive"
    1.28  
    1.29  fun update_hthm (Hthm {guh, coursedesign, mathauthors, thm, ...}) fillpats' =
    1.30    Hthm {guh = guh, coursedesign = coursedesign, mathauthors = mathauthors,