Lists as objects

I'm going to ask a specific question about Jens' recent project demo for the Robolot event where he implemented a simplified $1 gesture recognition system, but I suspect that the real trouble is that I don't understand something fundamental about how objects are passed around within Snap. Please know that I'm expecting the core problme to be my ignorance, and don't hesitate to point that out. :slight_smile:

This is the video of Jens presentation.

In it, he captures the points of a single movement gesture as a list of list(xpos,ypos) elements. Great!

Then he creates a resample function that lerps those points and returns a new list of specified length. Great!

Then he captures that returned list into a new list (called examples) along with a label value. That's around 32:00 in the video above.

In his example, this creates two element entry in the list examples.
examples[1][A] is the list containing all of the points of the interpolated drawing.
examples [1][B] is a descriptive string for that drawing.

When I tried to recreate this later, I found that add(list( (resample of sketch)(name) )) created an element for every point of the interpolated sketch (from 1A to 1LLL) and a second entry for the label.

I don't know how to put my specific blocks in a forum post, and all I have of Jens' work is what's shown in the video.
I'm unsure wether this is an error in my handling of the sampled list, or of my understanding of lists, or just a weird display error.

In linking the project below, I noticed that the list looked fine on the project page. So I tried this.
Recreate the empty list:

Add the interpolated list and name to examples. It displays across the columns.

Save and reload the project page. List displays "neat" with 1A as a single list object.

Reopen project. List is neat and new entries also come in neat.

forgot to link the project:
https://snap.berkeley.edu/project?user=tieandjeans&project=%241%20Gesture%20copy%2001

--andrew

When looking at lists that contain lists that contain .... etc etc :slight_smile: the view changes depending on the level your looking at

So all the shapes

image

each shape
image

The list of points of a shape

image

A single point of a shape

image

What Simon (cymplecy) said, combined in one picture:

Ok, thank you for that @cymplecy. It's helpful to know that this is a change in view, not a change in behavior. I thought I was missing some extra "wrap it up" process.

Thanks to @kinestheticlearning for showing off the right click tools to dig deeper into the layers when the more compact view is shown. I don't see equivalent "smoosh it all up" tools in the menu, but it's nice to know that when the project is opened the list defaults to the most compact/abstracted view.

--andrew

just right-click a script, then click script pic, and you'll download a picture of a script. On reporters, there's an option for result pic, which downloads a picture of the block and the result.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.