Skip to content

Instantly share code, notes, and snippets.

@chriskuech
Created May 5, 2019 04:48
Show Gist options
  • Save chriskuech/8e213433bb9acb25cb9d7222ae1b4b77 to your computer and use it in GitHub Desktop.
Save chriskuech/8e213433bb9acb25cb9d7222ae1b4b77 to your computer and use it in GitHub Desktop.
# names of the dimensions in the order that we take the cross product
$crossProductOrder = "Category1", "Category2", "Category3"
# get the object's identity vector, as member of the cross product
function Get-Vector([psobject] $obj) {
$crossProductOrder | % {$obj.$_}
}
# get the path to the object in the file system
function Get-VectorPath([psobject] $obj) {
(Get-Vector $obj) -join "/"
}
# get the values at the intersection of the sets defined by `$vector`
$vector = "category1value", "category2value", "category3value"
$vectorPath = "$container/$($vector -join "/").json"
Get-Content $vectorPath | ConvertTo-Json
# set the object
$obj | ConvertTo-Json | Out-File (Get-VectorPath $obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment