Future Dream? -> Functional Programming extension for C2

Discussion and feedback on Construct 2

Post » Fri Nov 28, 2014 5:25 am

Hi (@Ashley)

For player data collection/instrumentation I have an elaborate data structure of dictionaries included in other dictionaries, yielding plenty of hierarchical json. I notice that it requires a lot of loop programming.

It would be great if C2 would have a functional programming extension that would allow applying function to Arrays and Dictionaries, and/or more specifically a map reduce extension.

Is my requirement common? If yes, could this be done?
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Fri Nov 28, 2014 10:54 am

There is a 3rd party HashTable plugin that does what you want. I suggest using that for nesting data groups.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Fri Nov 28, 2014 11:27 am

Thanks. Looks interesting, but its just a first step towards what i am looking for.

What i need, essentially, is a the application of a select function, to generate selected entries (recursively, if needed), and then an apply function that applies to all results another function. The functions could be C2 functions with parameters, and perhaps a special parameter called "this" if needed.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Fri Nov 28, 2014 3:05 pm

You can use strings with tokenat() in dictionaries, or arrays.
Its not keypair, more like csv.
Image ImageImage
B
171
S
50
G
179
Posts: 8,392
Reputation: 113,478

Post » Fri Nov 28, 2014 3:57 pm

I know where your coming from, from wanting nested json hierarchies so I wrote that in an ES myself. It's a pain. However I don't get what your saying what you want. Could you please try again maybe with a diagram of some sort. Maybe there is a storage plugin that does as you want. Maybe someone can offer an alternative as newt provided.

From what I understand is that you want to start one function to look through the entire storage, and then when finding an entry to call a callback function?
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Fri Nov 28, 2014 3:59 pm

@grossd, I run into this problem a lot, where construct's primitive (flat) data structures aren't adequate to express many many things. Thankfully we have the SDK.

What I usually end up doing is use the SDK to create a plugin or behavior that hides the data structures, as well as any functions required (push, pop, map/reduce, splice).

Those objects are usually not documented, niche and/or too complex for general use, so I don't release them to the public.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Fri Nov 28, 2014 4:07 pm

Or @Yann 's JSON plugin. It is more completed then mine.
B
109
S
27
G
277
Posts: 4,482
Reputation: 154,924

Post » Fri Nov 28, 2014 4:48 pm

Hopefully this will all be sorted when we have a more extensible IDE :)

I'd love to integrate something like this directly in the editor.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Fri Nov 28, 2014 10:05 pm

@Fimbul
I so agree. I feel with major features with C2 winding down or impossible for C2; that it's time to start laying out the ground work for C3. As Ashley said. r200 will just be like any other release.

Thanks Rex. I like Yans plugin.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Sat Nov 29, 2014 4:09 pm

@all

I think that the C2 programming "language" and environment is fantastic.

It's even driven paradigm, and its include sheets, allows programming constructions that are hard to accomplish in "traditional" languages, including Java and the like. It would be great if C3 could build on its strength and selectively (and carefully) add some "software engineering" constructs, to make larger code more maintainable.

This could include native support for state machines, making functions a first class entity, rather than string only, support and perhaps even named approaches to define, reuse, adapt (inherit?) event expressions.

I dream of a general purpose web programming environment build on a C3 type of paradigm. Its no-nonsense, and much easier to use than, say, Javascript, with its numerous programming idioms.

@jayderyu.

I think a good example to think about is Wolfram's Mathematica, It's a functional language with which you can process list and recursive structures in a very elegant way.

Instead of say ("procedural code):

for each (ArrayA): ArrayA.currentValue>5, ArrayB.push(Array.currentValue)

you write (in functional pseudo code):

Push(ArrayB ,Select(x >5, ArrayA), ArrayB))

Or, sometimes, like this (using a pipe function "=>"):

Select(x >5, ArrayA) => Push(ArrayB)


Javascript, btw, does support functional programming to some good extent.

@Rex. Thanks, the json plugin sounds very promising, to help with a path oriented approach to navigating to relevant data in hierarchical json structures.

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests