packages feed

funcons-simple-0.1.0.3: tests/Kexceptions/Kexceptions06.fct

initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope
  (collateral (bind
    ("x",
     allocate-variable (values)),
  bind
    ("f",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("main",
     allocate-variable (functions
       (tuples ((values)*),
        values)))),
   sequential (null,
   assign
     (bound ("f"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("y",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (scope
           (bind
             ("t",
              allocate-initialised-variable
                (values,
                 decimal-natural ("1"))),
            sequential
              (handle-thrown
                (sequential
                  (print (assigned (bound ("t")),
                  " "),
                   print (decimal-natural ("8"),
                   " ")),
                 scope
                   (bind
                     ("p",
                      allocate-initialised-variable
                        (values,
                         given)),
                    print (integer-add
                      (assigned (bound ("p")),
                       decimal-natural ("10"))))),
               scope
                 (bind
                   ("i",
                    allocate-initialised-variable
                      (values,
                       decimal-natural ("1"))),
                  while
                    (is-less-or-equal
                      (assigned (bound ("i")),
                       assigned (bound ("y"))),
                     sequential
                       (effect (give
                         (integer-multiply
                           (assigned (bound ("t")),
                            assigned (bound ("i"))),
                          sequential
                            (assign
                              (bound ("t"),
                               given),
                             given))),
                        effect (give
                          (bound ("i"),
                           sequential
                             (assign
                               (given,
                                integer-add
                                  (assigned (given),
                                   1)),
                              assigned (given))))))),
               return (assigned (bound ("t"))))))))),
   assign
     (bound ("main"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (sequential
           (effect (give
             (decimal-natural ("5"),
              sequential
                (assign
                  (bound ("x"),
                   given),
                 given))),
            print (apply
              (assigned (bound ("f")),
               tuple (assigned (bound ("x")))),
            "\n")))))),
   apply
     (assigned (bound ("main")),
      tuple ())))