Skip to content

Commit

Permalink
feat(predicates): update okp4/okp4d predicates documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bot-anik committed Mar 21, 2024
1 parent 5a45e1e commit 0c96ce2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions predicates/consult_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ results:
This scenario demonstrates the capability of a Prolog program to consult another Prolog program. This is useful for
modularizing Prolog programs and reusing code.
Note that the `:- multifile/1` directive is employed to enable a single predicate's definition to span several files.
In the absence of this directive, encountering a new definition would lead the compiler to overwrite the existing
predicate definition.

Here's the steps of the scenario:

- **Given** the CosmWasm smart contract "okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht" and the behavior:
Expand All @@ -89,8 +93,10 @@ message: |
}
}
response: |
:- multifile(program/1).
:- consult('cosmwasm:storage:okp412ssv28mzr02jffvy4x39akrpky9ykfafzyjzmvgsqqdw78yjevpqgmqnmk?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%225d3933430d0a12794fae719e0db87b6ec5f549b2%22%7D%7D&base64Decode=false').
a.
program(a).
```

- **Given** the CosmWasm smart contract "okp412ssv28mzr02jffvy4x39akrpky9ykfafzyjzmvgsqqdw78yjevpqgmqnmk" and the behavior:
Expand All @@ -103,24 +109,31 @@ message: |
}
}
response: |
b.
:- multifile(program/1).
program(b).
```

- **Given** the query:

``` prolog
consult('cosmwasm:storage:okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D&base64Decode=false'),
a, b.
program(X).
```

- **When** the query is run (limited to 2 solutions)
- **Then** the answer we get is:

``` yaml
has_more: false
variables:
variables: ["X"]
results:
- substitutions:
- variable: X
expression: "b"
- substitutions:
- variable: X
expression: "a"
```

### Consult several Prolog programs
Expand Down

0 comments on commit 0c96ce2

Please sign in to comment.