packages feed

funcons-simple-0.1.0.3: tests/Kdiverse/Kdiverse4.fct

initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope
  (collateral (bind
    ("x",
     allocate-variable (values)),
  bind
    ("a",
     allocate-nested-vectors (decimal-natural ("10"))),
  bind
    ("incx",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("zero",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("id",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("double",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("hoincx",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("hozero",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("hoid",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("hodouble",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("app0",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("app1",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("app2",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("map",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("printall",
     allocate-variable (functions
       (tuples ((values)*),
        values))),
  bind
    ("main",
     allocate-variable (functions
       (tuples ((values)*),
        values)))),
   sequential (null,
   null,
   assign
     (bound ("incx"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (effect (give
           (bound ("x"),
            sequential
              (assign
                (given,
                 integer-add
                   (assigned (given),
                    1)),
               assigned (given)))))))),
   assign
     (bound ("zero"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (return (decimal-natural ("0")))))),
   assign
     (bound ("id"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("x",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (return (assigned (bound ("x"))))))),
   assign
     (bound ("double"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("x",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (return (integer-multiply
           (decimal-natural ("2"),
            assigned (bound ("x")))))))),
   assign
     (bound ("hoincx"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (return (assigned (bound ("incx"))))))),
   assign
     (bound ("hozero"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (return (assigned (bound ("zero"))))))),
   assign
     (bound ("hoid"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (return (assigned (bound ("id"))))))),
   assign
     (bound ("hodouble"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (return (assigned (bound ("double"))))))),
   assign
     (bound ("app0"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("f",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (effect (apply
           (assigned (bound ("f")),
            tuple ())))))),
   assign
     (bound ("app1"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("f",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (return (apply
           (assigned (bound ("f")),
            tuple ())))))),
   assign
     (bound ("app2"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("f",
              allocate-initialised-variable
                (values,
                 given))),
           pattern closure (bind
             ("x",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (return (apply
           (assigned (bound ("f")),
            tuple (assigned (bound ("x"))))))))),
   assign
     (bound ("map"),
      function closure (scope
        (match
          (given,
           tuple (pattern closure (bind
             ("f",
              allocate-initialised-variable
                (values,
                 given))),
           pattern closure (bind
             ("x",
              allocate-initialised-variable
                (values,
                 given))))),
         handle-return (scope
           (bind
             ("i",
              allocate-initialised-variable
                (values,
                 decimal-natural ("0"))),
            while
              (is-less-or-equal
                (assigned (bound ("i")),
                 integer-subtract
                   (length (vector-elements (assigned (bound ("x")))),
                    decimal-natural ("1"))),
               sequential
                 (effect (give
                   (apply
                     (assigned (bound ("app2")),
                      tuple (assigned (bound ("f")),
                      assigned (checked index
                        (integer-add
                          (1,
                           assigned (bound ("i"))),
                         vector-elements (assigned (bound ("x"))))))),
                    sequential
                      (assign
                        (checked index
                          (integer-add
                            (1,
                             assigned (bound ("i"))),
                           vector-elements (assigned (bound ("x")))),
                         given),
                       given))),
                  effect (give
                    (bound ("i"),
                     sequential
                       (assign
                         (given,
                          integer-add
                            (assigned (given),
                             1)),
                        assigned (given))))))))))),
   assign
     (bound ("printall"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (sequential
           (print ("x = ",
           assigned (bound ("x")),
           ";  a[] = "),
            scope
              (bind
                ("i",
                 allocate-initialised-variable
                   (values,
                    decimal-natural ("0"))),
               while
                 (is-less-or-equal
                   (assigned (bound ("i")),
                    integer-subtract
                      (length (vector-elements (assigned (bound ("a")))),
                       decimal-natural ("1"))),
                  sequential
                    (print (assigned (checked index
                      (integer-add
                        (1,
                         assigned (bound ("i"))),
                       vector-elements (assigned (bound ("a"))))),
                    " "),
                     effect (give
                       (bound ("i"),
                        sequential
                          (assign
                            (given,
                             integer-add
                               (assigned (given),
                                1)),
                           assigned (given))))))),
            print ("\n")))))),
   assign
     (bound ("main"),
      function closure (scope
        (match
          (given,
           tuple ()),
         handle-return (sequential
           (effect (give
             (decimal-natural ("0"),
              sequential
                (assign
                  (bound ("x"),
                   given),
                 given))),
            scope
              (bind
                ("i",
                 allocate-variable (values)),
               sequential
                 (scope
                   (bind
                     ("i",
                      allocate-initialised-variable
                        (values,
                         decimal-natural ("0"))),
                    while
                      (is-less-or-equal
                        (assigned (bound ("i")),
                         integer-subtract
                           (length (vector-elements (assigned (bound ("a")))),
                            decimal-natural ("1"))),
                       sequential
                         (effect (give
                           (assigned (bound ("i")),
                            sequential
                              (assign
                                (checked index
                                  (integer-add
                                    (1,
                                     assigned (bound ("i"))),
                                   vector-elements (assigned (bound ("a")))),
                                 given),
                               given))),
                          effect (give
                            (bound ("i"),
                             sequential
                               (assign
                                 (given,
                                  integer-add
                                    (assigned (given),
                                     1)),
                                assigned (given))))))),
                  effect (apply
                    (assigned (bound ("printall")),
                     tuple ())),
                  effect (apply
                    (apply
                      (assigned (bound ("hoincx")),
                       tuple ()),
                     tuple ())),
                  print (assigned (bound ("x")),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("hozero")),
                       tuple ()),
                     tuple ()),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("hoid")),
                       tuple ()),
                     tuple (decimal-natural ("7"))),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("hodouble")),
                       tuple ()),
                     tuple (decimal-natural ("7"))),
                  "\n"),
                  effect (apply
                    (apply
                      (assigned (bound ("id")),
                       tuple (apply
                         (assigned (bound ("hoincx")),
                          tuple ()))),
                     tuple ())),
                  print (assigned (bound ("x")),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("id")),
                       tuple (apply
                         (assigned (bound ("hozero")),
                          tuple ()))),
                     tuple ()),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("id")),
                       tuple (apply
                         (assigned (bound ("hoid")),
                          tuple ()))),
                     tuple (decimal-natural ("7"))),
                  " ",
                  apply
                    (apply
                      (assigned (bound ("id")),
                       tuple (apply
                         (assigned (bound ("hodouble")),
                          tuple ()))),
                     tuple (decimal-natural ("7"))),
                  "\n"),
                  effect (apply
                    (assigned (bound ("app0")),
                     tuple (apply
                       (assigned (bound ("id")),
                        tuple (apply
                          (assigned (bound ("hoincx")),
                           tuple ())))))),
                  print (assigned (bound ("x")),
                  " ",
                  apply
                    (assigned (bound ("app1")),
                     tuple (apply
                       (assigned (bound ("id")),
                        tuple (apply
                          (assigned (bound ("hozero")),
                           tuple ()))))),
                  " ",
                  apply
                    (assigned (bound ("app2")),
                     tuple (apply
                       (assigned (bound ("id")),
                        tuple (apply
                          (assigned (bound ("hoid")),
                           tuple ()))),
                     decimal-natural ("7"))),
                  " ",
                  apply
                    (assigned (bound ("app2")),
                     tuple (apply
                       (assigned (bound ("id")),
                        tuple (apply
                          (assigned (bound ("hodouble")),
                           tuple ()))),
                     decimal-natural ("7"))),
                  "\n"),
                  effect (apply
                    (assigned (bound ("map")),
                     tuple (assigned (bound ("double")),
                     assigned (bound ("a"))))),
                  effect (apply
                    (assigned (bound ("printall")),
                     tuple ()))))))))),
   apply
     (assigned (bound ("main")),
      tuple ())))