summaryrefslogtreecommitdiff
path: root/tests/factorial.wat
blob: 3d98dd413987eee5325186e7d091c148c829d06f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
;; SPDX-FileCopyrightText: 2025 orangerot <me@orangerot>
;;
;; SPDX-License-Identifier: GPL-3.0

(module
  (func $fac (export "fac") (param f64) (result f64)
    local.get 0
    f64.const 1
    f64.lt
    if (result f64)
      f64.const 1
    else
      local.get 0
      local.get 0
      f64.const 1
      f64.sub
      call $fac
      f64.mul
    end))