"run (_) with inputs [_] ►" help

I get you run blocks within the "(_)" ring, but what about the "with inputs [_] ►" part? What exactly does the "with inputs" accomplish that the ("["((_) + (_))", "((_) - (_))", "((_) x (_))", "((_) / (_))", "((_) ^ (_))"] blocks can't?

To prevent the italics, use \_.

Anyway, see the Snap! manual, page 61.

Or, more specifically, see the section in it called "Call/Run with inputs".

Or, alternatively, have Brian tell you, as he is no doubt doing right now.

Well first of all everything isn't arithmetic.

But the main thing I think you're missing is that the first input to CALL or RUN isn't necessarily a fixed block -- in fact, it hardly ever is, except in examples in the manual. The more usual case is something like


where the thing to focus on right now is "CALL (FUNCTION) ..." You can't just drag an input into the function block because the function block is provided by the caller of MAP.

:~P

Yeah but how do I edit the post to remove the italics though :confused:

Hey, nevermind. I somehow got the option to edit... unsure to how that occurred. Anyways , thanks for the info! Now can someone tell me what exactly w/continuation does?

Nope, you have to read the manual.

I read it though, I do not understand the meaning of this block

Okay, if you read it, then you have to ask a more specific question. Where in the continuations chapter did you get lost? Or something.

Page 94, I am unsure what the difference is between "call with inputs" and "call w/continuation" is

Okay, let's try this. Pretend there were a block untitled script pic that reports the continuation of its caller. Then these two expressions are equivalent:
untitled script pic (1)

Does that help? Did you understand the multiplication example on page 93 that's supposed to help you understand what a continuation means?

What is the caller continuing? Like, is it continuing a block, and reporting the true/false value of that happening? I even tested this in Snap! Itself, and It doesn't make much sense to me

image

Also I can't find this "prime" block anywhere
image

Oh. Starting with the easy part, PRIME? isn't built into Snap!; you have to write it. It can be done many ways, but my favorite way directly expresses the definition of prime: "a number that has no factors other than itself and 1":


(It shouldn't really need the n=2 check, but NUMBERS FROM 2 TO 1 doesn't report an empty list as it arguably should. The IS...EMPTY? part is the good part!)

Oh... now you'll want this:
untitled script pic (1)

Now for the hard part. This is the hardest-to-understand part of Snap!, so it's not surprising that you're having trouble with it.

What is the caller continuing?

The caller isn't continuing anything. The question should be, "What continues the caller?" In other words, when the caller (the caller of call/cc, I mean) reports a value, what will be done with this value?

The error you're getting from YIELD has nothing to do with continuations; it's that YIELD works only once you've initialized TASKS to an empty list. (See the when-green-flag-clicked script on page 96.)

So, first of all, in this thread system, nothing actually runs until the END THREAD block, after all the threads have been set up. It's the RUN block inside END THREA that starts the whole system running.

So the continuation of a YIELD includes these parts:

  1. What comes after the YIELD in the thread itself.
  2. What comes after that RUN inside END THREAD.
  3. What comes after the call to END THREAD in its script.

Part 1 is the rest of a FOR loop. So, in the number thread, say I is 5 (it has to be prime in order for the YIELD to run). Then the continuation inside the thread is

for i = 6 to 30
  ...

If there were more code below the FOR loop in the thread, that would be part of the continuation too, but in this example there isn't.

Part 2 is empty, because nothing comes after the RUN in END THREAD. (If that IF block were a looping block rather than a conditional block, then the rest of the loop would be included.)

Part 3 is also empty, because every call to END THREAD comes at the end of its script. If the green-flag script had more instructions after the END THREAD, then those instructions would be part of the continuation of every thread.

But, what happens after the call to YIELD isn't its continuation! That continuation is added to the TASKS list, and then a different continuation is run, namely, whichever thread's turn it is. (If there's only one thread still wanting to run, then before the call to YIELD, TASKS is empty, so this task itself is added to the task list and then immediately removed from it and run.)

Does that help?

I finished the script from the Manual, the "tasks" is now an empty list. The script now runs and has no errors.

Anyways, I did some testing, and it seems the difference between run with inputs, and run w/continuation is ... It adds a reporter ring to the variable? Because continuation is set to a reporter ring when run w/continuation, but set to nothing when run with inputs

Don't focus too much on the notation. Yes, it's true that a continuation is a procedure, and like any other procedure when used as a value, it's displayed in a ring.

But the big difference is that with RUN WITH INPUTS you provide the input values. In RUN WITH CONTINUATION, the input is this very special thing, a continuation, that Snap! provides.

I'm not sure, but I have the feeling that you don't entirely understand procedures as data, and so you're running a little ahead of yourself by grappling with continuations. Read Chapter VI, Procedures as Data, page 61.

I have finished the custom "for (i) = 1 to 10" and custom "map (_) over (=)" blocks, they work just fine...

Which part was I supposed to focus on from that?

Oh, it's not that you had to build the scripts, so much as reading the explanation of what a gray ring means. And the explanation of how actual arguments in a CALL are attached to empty slots or formal parameters of the ringed expression.

I suggested it because you sounded uncertain about the way a continuation is provided by CALL W/CONTINUATION as an input to the script you give it as input.

...I was actually uncertain to why the reporter ring was empty

Am I supposed to set it to something?
image

for getting inputs into a function

What type of function?