24 lines
508 B
Text
24 lines
508 B
Text
inductive Expr where
|
|
| app (f : String) (args : Array Expr)
|
|
|
|
def Expr.size (e : Expr) : Nat := Id.run do
|
|
match e with
|
|
| app f args =>
|
|
let mut sz := 1
|
|
for h : i in [: args.size] do
|
|
sz := sz + size (args.get ⟨i, h.upper⟩)
|
|
return sz
|
|
|
|
namespace Ex2
|
|
inductive Expr where
|
|
| app (f : String) (args : List Expr)
|
|
|
|
def Expr.size (e : Expr) : Nat := Id.run do
|
|
match e with
|
|
| app f args =>
|
|
let mut sz := 1
|
|
for h : arg in args do
|
|
sz := sz + size arg
|
|
return sz
|
|
|
|
end Ex2
|