afizzycola / explicit-bitcoin-lib

A Bitcoin library written in Typescript and which provides explicit classes for use in Bitcoin development and testing
1 stars 0 forks source link

FututeGoose Code #23

Open afizzycola opened 3 years ago

afizzycola commented 3 years ago
class And {
    elements: Array<any> = [];
    constructor(array: Array<any>) {
        array.forEach(element => {
            //check what type it is
            //then push onto this.elements
        })
    }
}

class Or {
    elements: Array<any> = [];
    constructor(array: Array<any>) {
        array.forEach(element => {
            //check what type it is
            //then push onto this.elements
        })
    }
}

if (element.type === BmlTypes.AndGateway) {
    new And(ElementsOutgoingArray)
}
if (element.type === BmlTypes.AndGateway) {
    new Or(ElementsOutgoingArray)
}
afizzycola commented 3 years ago
const testStack = ["AND", 2, "Activity_10ttrdj", "OR", 2, "Activity_17ymcwz", "Activity_0nyqi0b"];

function generatePathsFromStack2(stack = []) {

    //flaten the ANDs
    let paths = [];
    const andI = stack.indexOf("AND");
    const numOfAndAugs = stack[andI + 1];
    stack.splice(andI, 2);
    console.log(stack);

    //resolve the ORs
    const orI = stack.indexOf("OR");
    const numOfOrAugs = stack[orI + 1];

    orSet = stack.splice(orI, orI + 2 + numOfOrAugs);
    console.log(orSet,numOfOrAugs );
    orArray = orSet.slice(2, 2 + numOfOrAugs);
    console.log(orArray);

    for (let i = 0; i < numOfOrAugs; i++) {
       paths.push(new Set().add(orArray[i]));
    }

    //apend ANDs to paths
    const finalThingToAdd = stack.shift();
    paths.forEach( path => {
        path.add(finalThingToAdd);
    })

    console.log(paths);
    console.log(stack);

}

generatePathsFromStack2(testStack);