Zero

Member

Last active 2 months ago

  1. 3 months ago
    Mon Aug 7 21:02:39 2017
    Zero started the conversation state superposition.

    quantum physics
    particles simultaneously in several states
    Schrödinger's cat both dead and alive
    state superposition
    same here
    some functions render several superposed values
    one world for each value
    ok since some nodes don't care
    keep track of worlds disjonctions
    1 world characterized by node-value pairs

  2. Mon Aug 7 20:58:10 2017
    Zero started the conversation Lazy spreadsheet.

    The whole thing is going to be a network of cells, where each cell holds values that depend on values from other cells. We'll use the observer pattern to propagate value modifications: each cell maintains a list of its dependents, called observers, and notifies them automatically of any state changes.

    A cell contains a bag. Values of the cells it observes are transfered to its bag, so the cell's value is calculated. When it's done, the cell is flagged up-to-date.

    It works like a spreadsheet. But we don't want values to be calculated automatically, because it would be a huge waste of energy. What we want is a lazy spreadsheet.

    When an observed cell changes its value, instead of propagating its new value, it just emits a need refresh message. When cells receive this message, they set their up-to-date flag to false and propagate the same message to all their observers, if it has not be done already.

    The system tends to be standing by. When a particular value, on a specific cell, is needed, if this cell's up-to-date flag is true, we get the value instantly. If it's false, the cell sends a calculate now message to the cells it observes, to get the new value.

    When a cell receives a calculate now message, if its value is up-to-date, it returns it, else it propagates the calculate now message to the cells it observes.

    So, we have two types of messages: the need refresh message, flowing from observed to observers, and the calculate now message, flowing from observers to observed.

    A "function" is no longer linear, but rather automatically determined to produce a value when needed, depending on what's already known and what's not yet. In this context, "calling" a function consists of: setting some cell's values (these are the parameters), sending a calculate now message to a target cell (this is the function call), and getting the target cell's value (the "return" value).

  3. Sat Aug 5 16:06:56 2017
    Zero posted in Bags.
    var log = function(x) { console.log(JSON.stringify(x,null,4));};
    
    var functionList = {
    
        sum: function(arg) {
            var result = 0;
    
            for (a in arg) {
                n = parseFloat(arg[a].value);
                if (!isNaN(n) && isFinite(n)) result += n;
            }
            return result;
        },
    
        avg: function(arg) {
            var result = 0;
            for (a in arg) {
                n = parseFloat(arg[a].value);
                if (!isNaN(n) && isFinite(n)) result += n;
            }
            return result/arg.length;
        },
    
        max: function(arg) {
            var result = null;
            for (a in arg) {
                n = parseFloat(arg[a].value);
                if (!result) result = n;
                else if (!isNaN(n) && isFinite(n) && (result<n))
                    result = n;
            }
            return result;
        },
    
        min: function(arg) {
            var result = null;
            for (a in arg) {
                n = parseFloat(arg[a].value);
                if (!result) result = n;
                else if (!isNaN(n) && isFinite(n) && (result>n))
                    result = n;
            }
            return result;
        }
    
    }
    
    
    var functionOrder = [
        "sum",
        "avg",
        "max",
        "min"
    ]
    
    
    var testBag = [
        {type:"number", value:5},
        {type:"function", value:"max"},
        {type:"number", value:8},
        {type:"number", value:6},
        {type:"function", value:"avg"},
        {type:"number", value:2},
        {type:"number", value:4},
        {type:"number", value:1}
    ]
    
    
    
    function highestRankFunction(bag) {
    
        var highest = functionOrder.length+1;
    
        for (var b in bag) {
            if ((bag[b].type=="function")
            && (functionOrder.indexOf(bag[b].value)>-1))
               if (functionOrder.indexOf(bag[b].value)<highest)
                    highest = functionOrder.indexOf(bag[b].value);
        }
        return functionOrder[highest];
    }
    
    
    function solveBag(bag) {
    
        var fun = highestRankFunction(bag);
    
        return functionList[fun].call(null,bag)
    }
    
    
    
    log("Result: "+solveBag(testBag));
    
    log('done');
    
  4. Thu Aug 3 14:58:32 2017
    Zero started the conversation Bags.

    If you put in a bag a number seven 7, a number two 2, a plus sign +, and a number three 3, a human mind would instantly know what can be done with these. We have an operator, three operands... we can sum the numbers, and get 12.

    Computers don't like bags. A typical programming language needs a particular syntax. For example (+ 7 2 3), or +(7, 2, 3), or 7 + 2 + 3. If you don't follow the syntax, you get a syntax error.

    Let's do bags. Let's get rid of syntax.

    It's quite easy to do if you're sure you have only one operator, and the right operands. But if we put a string in our first bag, how do we add numbers and strings? And if we put a second operator, for example *, should we sum numbers or multiply them? Our bag seems unusable in these situations.

    To solve the several operators issue, we need ordering.

    Imagine we have 50 possible functions. If we order them, we can choose what to do when there are several functions in a bag. Our 50 functions list looks like:

    1. sum
    2. multiply
    3. max
    4. min
    5. ...etc.

    If there are several functions in a bag, the highest rank function is selected. Problem solved.

    Now what if we put strings in a bag that's about to multiply things. Well we can just ignore them. Problem solved.

    What good are bags anyway?

    They're good at connecting things without relying on a pre-existing infrastructure.

  5. Thu Aug 3 12:58:32 2017
    Zero joined the forum.