$include "defs.icn"
$include "global_vars.icn"
#
# cor_cond(d1, d2)
#
# input: d1,d2 are syntax trees coresponding to some denotation.
#        They should be lists with a single element.
#
# output: the syntax tree corresponding to (d1 cor d2), i.e.
#         corresponding- to  IF d1 ==> Boolean$true[] # ELSE ==> d2 FI.
#

procedure cor_cond(d1, d2)
    local gl, ge1, ge2

    if (d1.is_empty() | d2.is_empty()) then {
	return(mknode([GUARDEDLIST, emptylist()]))
    }
    ge1 := mknode([GUARDEDELEMENT, d1.first(), sel_true])
    ge2 := mknode([GUARDEDELEMENT, mknode([WORDELSE]), d2.first()])
    gl := mknode([GUARDEDLIST, mklist([ge1, ge2, -1])])
    return( gl )
end

