Thursday, August 1, 2019

Learning CL Day 7: Coolcoolcool

First I'm going back over my previous posts to check for unanswered questions, which I already went back and bolded a few days ago so I could find them easily.

On day 1: I wondered about the word script in this line:
content: note3.script.greeting
and it reminds me of something I wondered about yesterday, and that is the seeming interruption of the sequence sinktype: label.sourcetype with words like script, or simpleFunction.

On day 2: I wondered about the example under the heading "Sources" involving latex and variables, and I remember starting to feel very anxious right around then. Here's what I said:
content: "
You entered: ${l}
which evaluates to: ${v}"
Earlier in the script the variables v and l are defined:
v = exp5.numericValue
l = exp5.latex
and both those variables belong to exp5, which is the name of the input. So does this mean the exp5 is the source here? I typed 4^2 into the input and it got injected into the note AND the input. Soooooo the input is the source and the sink here?
Now I think I know a bit more about what was happening there. So hmmm. What gets typed into the input (labelled exp5) is displayed in two places - obviously right in exp5, but also in the note. So it seems true that the input (exp5) is both a source and a sink. But whatever gets typed is also a source for the note, which explains why the script is behind the note's gearbox. But now I'm wondering what is making the 4^2 to be displayed properly AND get evaluated right in the input box? I did an experiment and deleted the note completely, which means there is no longer any CL or script. I typed 4^2 and this happened:

Which tells me that the lovely folks at Desmos take care of that without any CL being necessary. As soon as you select f(x)math for a note, it interprets what you type as latex, and it evaluates it. 

I know that I knew that already on some level, but NOW I REALLY KNOW IT.

On day 3: This is where I first encountered simpleFunction. Hopefully today its placement in the script will start making more sense.

All the other days had no open questions, so I'm ready to move on.

I feel like I need to re-read the CL doc, because I had stepped away to try other things out and immerse myself in examples. Time to go back and un-overwhelm myself, and to get a better handle on that secret sauce: Variables.


So you can call a variable anything I guess, and you define it by what's on the other side of the equals sign. You can have something in quotations, like:
greeting = "hello, world!"
Or it can be whatever's in another component (which is the source for that variable), which has a label, like:
v = exp5.numericValue
in which case we need to also specify the data type of that component (or source) that we want to extract, because there are other types, like:
l = exp5.latex
You can also define a variable right inside the script for a sink, without any equals sign, but using brackets and quotations, like this:
number("m"): exp1.numericValue
which was in the guess-the-slope-of-this-line example, but in order for things to work, the variable m had to be in the graph itself, as y = mx. So one way or another, there has to be an equals sign involved in the definition of a variable.

Another new word I see in this section is "keyword", in this example:

I wonder if "keyword" has a specific meaning in the CL syntax world?

Also I still feel unsure of when a variable is needed, and when it's not.


Aha. "We have a few built-in functions for interpreting sources and converting between data types." Perhaps this is where those seeming interruptions (script, simpleFunction) come in. From the examples, it looks like these built-in functions go into the script after the equals, then are followed by brackets, which contain the expected sourcelabel.sourcetype. However, all the examples are variable definitions, so I'm wondering if these built-ins can be invoked for sinks as well?


This seems more familiar, maybe because I've recently been putting a lot of Conditionals in my GeoGebras, which uses the If-then-else structure, equivalent to when-otherwise. Did the Try it preview first. The student enters a number in the input, and  a message, entirely text, no numeric part, is immediately displayed in the notes above it. But what message is displayed depends on the number input. So let's see if I can predict any of the the script:

The source is the input box, so that must be labelled exp1 or something.
There must be a variable defined for whom the source is exp1, like n = exp1.numericValue .
f(x)math must be selected on the input
There must be script in the note's gearbox something like content."text message" and there must be a few when lines for different values of n.

Checking: The input is labelled "number" instead of note1, ok.
I got the variable definition syntax right.
f(x)math is indeed selected.
I was right about the content dot part and the whens. Yay! Also, the various text messages are enclosed in quotation marks, and a built-in "isUndefined(n)" is also there to display nothing when whatever was typed in wasn't a number.

Getting somewhere, coolcoolcool!

Tomorrow, I'll start watching Jay Chow's webinars.

No comments:

Post a Comment