1:
|
val substitute: y : Expression -> r : Expression -> x : Expression -> Expression
|
Заменяет одну часть в выражении (Expression) на другую
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
|
let print = Infix.format >> printfn "%s"
let expr = "3*x*y + 2*x + sin(x)*3*x*y" |> Infix.parseOrUndefined
let _from = "3*x*y" |> Infix.parseOrUndefined
let _to = "2*z" |> Infix.parseOrUndefined
print expr
printf "Replace:\nOld value: "
print _from
printf "New value: "
print _to
Structure.substitute _from _to expr
|> print
|
1:
2:
3:
4:
5:
|
2*x + 3*x*y + 3*x*y*sin(x)
Replace:
Old value: 3*x*y
New value: 2*z
2*x + 2*z + 3*x*y*sin(x)
|