Skip to content

Instantly share code, notes, and snippets.

@Capital-EX
Created November 18, 2023 19:37
Show Gist options
  • Save Capital-EX/26ebae7bf6d465c3b6b4034d301203a2 to your computer and use it in GitHub Desktop.
Save Capital-EX/26ebae7bf6d465c3b6b4034d301203a2 to your computer and use it in GitHub Desktop.
Starting state:
(1) ..s                           | [ int - int - int ] swap 'x set apply 'x get
    Inferred Effect: [ ..s -- ..t ]

(2) ..s [ int - int - int ]       | swap 'x set apply 'x get
    Inferred Effect: [ ..s -- ..t ]

(3) ..s [ int - int - int ] x     | 'x set apply 'x get
    Inferred Effect: [ ..s x -- ..t ]

(4) ..s [ int - int - int ] x 'x  | set apply 'x get
    Inferred Effect: [ ..s x -- ..t ]

(5) ..s [ int - int - int ]       | apply 'x get
    Inferred Effect: [ ..s x -- ..t ]

(6) ..s                           | int - int - int 'x get
    Inferred Effect: [ ..s x -- ..t ]

(7) ..s int                       | int - int 'x get
    Inferred Effect: [ ..s x -- ..t ]

(8) ..s                           | int - int 'x get
    Inferred Effect: [ ..s int x -- ..t ]

(9) ..s int                       | - int 'x get
    Inferred Effect: [ ..s int x -- ..t ]

(a) ..s                           | int 'x get
    Inferred Effect: [ ..s int int x -- ..t ]

(b) ..s int                       | 'x get
    Inferred Effect: [ ..s int int x -- ..t ]

(c) ..s int 'x                    | get
    Inferred Effect: [ ..s int int x -- ..t ]

(d) ..s int x                     | 
    Final Effect: [ ..s int int x -- int x ..t ]

( 1 ) Begin execution with a free row-variable

( 2 ) Push the quotation [ int - int - int ]

( 3 ) Generate x from ..s, then swap x and [ int - int - int]

( 4 ) Push 'x

( 5 ) Move x into 'x

( 6 ) Apply [ int - int - int ]

(7-a) Push int, then generate int from ..s to unify against

( b ) Push final int

( c ) Push 'x

( d ) Read 'x restoring x, move items left on stack to output side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment