vault backup: 2025-03-24 22:16:49
All checks were successful
Update pages on webserver / Update (push) Successful in 5s

This commit is contained in:
themodernhakr 2025-03-24 22:16:49 -05:00
parent 45da08e34b
commit 620bd29a29

View File

@ -6,6 +6,7 @@ While working on my Database datapack (still WIP), I knew I'd want to find
# Scenario # Scenario
## Dataset ## Dataset
The data is stored in a storage `#_macro.array`. Array is populated with a total of 500 entries, each having a `id` and `string` fields.
```json ```json
[ [
{ {
@ -20,14 +21,16 @@ While working on my Database datapack (still WIP), I knew I'd want to find
] ]
``` ```
## Constraints ## Constraints
The objective is to create an interface that receives a keyword, say `entry500`, and searches the array for an entry where the value of `string` matches the keyword.
# One Macro # One Macro
Macros allow us to reach into our array and pick out an entry that matching value in the `string` property. Macros allow us to reach into our array and pick out an entry that matching value in the `string` property.
```haskell ```vb
> one_macro.array[string:$(keyword)] ... one_macro.array[string:$(keyword)]
``` ```
```haskell ```vb
-- one_macro/run.mcfunction '# one_macro/run.mcfunction
data modify storage test_namespace:test_namespace temp.keyword set value 'entry500' data modify storage test_namespace:test_namespace temp.keyword set value 'entry500'
@ -37,14 +40,14 @@ data remove storage test_namespace:test_namespace temp.keyword
data remove storage test_namespace:test_namespace temp.result data remove storage test_namespace:test_namespace temp.result
``` ```
```haskell ```vb
-- one_macro/_searcharray.mcfunction '# one_macro/_searcharray.mcfunction
$data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace one_macro.array[string:$(keyword)] $data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace one_macro.array[string:$(keyword)]
``` ```
# Two Macro # Two Macro
```vb ```vb
' two_macro/run.mcfunction '# two_macro/run.mcfunction
data modify storage test_namespace:test_namespace temp.keyword set value 'entry500' data modify storage test_namespace:test_namespace temp.keyword set value 'entry500'
@ -58,13 +61,13 @@ data remove storage test_namespace:test_namespace temp.result
``` ```
```vb ```vb
' two_macro/_searchindex.mcfunction '# two_macro/_searchindex.mcfunction
$data modify storage test_namespace:test_namespace temp.index set from storage test_namespace:test_namespace two_macro.index.$(keyword) $data modify storage test_namespace:test_namespace temp.index set from storage test_namespace:test_namespace two_macro.index.$(keyword)
``` ```
```vb ```vb
' two_macro/_searcharray.mcfunction '# two_macro/_searcharray.mcfunction
$data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace two_macro.array[$(index)] $data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace two_macro.array[$(index)]
``` ```