Skip to content
Snippets Groups Projects
Commit b4e2d678 authored by Kieran van Gaalen's avatar Kieran van Gaalen
Browse files

Implemented aboveappend and belowappend

parent 98cd78b5
No related branches found
No related tags found
1 merge request!1Big merge
......@@ -369,16 +369,22 @@ func FuncToAllRel(JSONQuery *entity.IncomingQueryJSON, function pdict) {
}
}
// TODO
// Write a function that appends 1 level above
func AboveAppend() {
// A function that appends 1 level above (if index is 0 this won't work)
func AboveAppend(index int, value []pdict) [][]pdict {
if index == 0 {
return prepend(listoflists, value)
}
return BelowAppend(index-1, value)
}
// TODO
// Write a function that appends 1 level below
func BelowAppend() {
// A function that appends 1 level below (thanks to wasmup on stackoverflow)
func BelowAppend(index int, value []pdict) [][]pdict {
if len(listoflists) == index { // nil or empty slice or after last element
return append(listoflists, value)
}
listoflists = append(listoflists[:index+1], listoflists[index:]...) // index < len(a)
listoflists[index] = value
return listoflists
}
// A simple double-for loop that finds the layer in which an element resides in the hierarchy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment