Ai Dreams Forum

Member's Experiments & Projects => AI Programming => Topic started by: Zero on July 06, 2018, 01:53:31 pm

Title: Flowing tables
Post by: Zero on July 06, 2018, 01:53:31 pm

Here is a rather serious project (yeah, every once in a while, I need to post serious stuff) about a very specific model of computation.

It is strongly inspired from spreadsheets, as you can see:


    table Scores apprenants

        row Apprenants
            list
                Joseph
                Pierre
                Paul
                Jacques
            end
           
        row Moyenne par matière
            average
                Apprenants
            end
       
        col Notes
            list
                Maths
                Français
                Histoire
            end
           
        col Moyenne par apprenant
            average
                Notes
            end
       
        val Apprenants \ Notes
            constant
                15, 18, 13
                12, 08, 09
                05, 15, 16
                19, 12, 11
            end
       
    end


(sorry for the lack of translation)

This piece of code corresponds to a simple, classical spreadsheet table that would look like this:


+---------------------+----------+----------+----------+-------------+
|   Scores apprenants |   Maths  | Français | Histoire | Moyenne par |
|  Apprenants \ Notes |          |          |          |  apprenant  |
+---------------------+----------+----------+----------+-------------+
|              Joseph |    15    |    18    |    13    |     15.3    |
|              Pierre |    12    |     8    |     9    |      9.7    |
|                Paul |     5    |    15    |    16    |     12.0    |
|             Jacques |    19    |    12    |    11    |     14.0    |
+---------------------+----------+----------+----------+-------------+
| Moyenne par matière |   12.8   |   13.3   |   12.3   |
+---------------------+----------+----------+----------+


You're probably wondering, what's the point.

The point is to make flow-based programming using tables. For example, rows and cols headers are defined as constant lists in this example, but it needs not be the case. These lists could be obtained from a filter or a map function. Same goes for values: in this example, they are constant, but they can also be obtained from other tables.

It's different from a typical spreadsheet, since cols and rows header lists are always growing and shrinking, as time steps.

Programming here is done by setting up table declarations that define how a table's headers and values are calculated using data from other tables at the previous time step.

Any calculus applicable to lists can be used to calculate the lists of rows and cols headers. Values themselves can be anything, including strings, lists, objects, ...etc, depending on the host programming language, which could be Python or Javascript for instance.

My first idea was to authorize any number of dimensions, but it turns out it's hard for the human brain to visualize more-than-3D tables, so I've decided to keep it 2D. Anyway, you can obtain the same effect with additional tables, since the rows or cols headers list of one table can be obtained from the value list from another table: then you've got 3D. If you do it again, you've got 4D and so on.

There's probably tools like that "Flowing tables" thing out there already.

Title: Re: Flowing tables
Post by: spydaz on July 06, 2018, 02:11:47 pm
Usually in this situation i would use a List Object (creating a structure / Type)

Public Structure StudentScore
     Public Student as String
     Public Maths as Double
     Public Francais as Double
     Public History as Double
     Public TotalAverage as Double
End Structure

Public Structure ClassTermScores
     Public Students as List (of studentScore)
     Public AvgClass as double
     Public AvgMaths as Double
     Public AvgFrancais as Double
     Public AvgHistory as Double
     Public TotalAverage as Double
End Structure

Usually i would also Make an averaging function for Students so that the variable which need calculating would auto calculate as students are added to the list

Its not so bad in vb.net

IT can be further refined to Accommodate Random Classes by creating a Class structure instead using inheritance; Then it would contain a list of ClassTopics ... etc... i dot often use the object technique to define my data structures ... but often it can allow for generic additions with changes in the main class just inherit again... this means class objects can be sealed at higher levels... But i prefer structured lists as the compiler handles them with the same rules as variables... maintaining integrity.. where as data within a class object often become changed after interrogation...
But both can be loaded by a Comma Separated, list... adding , removing , updating , calculation are all easy with such lists.

Title: Re: Flowing tables
Post by: ranch vermin on July 06, 2018, 07:51:40 pm
automated spreadsheets are powerful nerd equipment.