spender - : .
spender, , , , . (CPS - , .)
, CPS- , (1) (2) ML, #. :
children node .cost node.- , .
-, CPS ML:
let rec maximum_path_cost node =
let rec aux nodes max =
match nodes with
| [] -> max
| head :: tail ->
let c = maximum_path_cost head in
let new_max = if c > max then c else max in
aux tail new_max
in
(cost node) + (aux (children node) 0)
: , . : " ?" , ; , ( ), .
, aux , maximum_path_cost .
max_path_cost - - , int - , . aux .
CPS.
let rec maximum_path_cost node continuation =
let rec aux nodes max aux_continuation =
match nodes with
| [] -> aux_continuation max
| head :: tail ->
let mpcc c =
let new_max = if c > max then c else max in
aux tail new_max aux_continuation
in
maximum_path_cost head mpcc
in
let ac result =
continuation ((cost node) + result)
in
aux (children node) 0 ac
, , , . , , aux max, ; aux? , _path_cost. ? .
# # .:)