Message Boards Message Boards

10
|
24230 Views
|
302 Replies
|
227 Total Likes
View groups...
Share
Share this post:
GROUPS:

[WSG24] Daily Study Group: Programming Proficiency

A Wolfram U Daily Study Group previewing our upcoming Programming Proficiency course sequence begins on Monday, January 29, 2024. The study group will run for ten days through February 9, and each day will run from 11AM to noon CDT.

Join me, @Abrita Chakravarty and a cohort of fellow enthusiasts to build a strong foundation for any and all sorts of Wolfram Language programming that you'll do in the future. We'll cover everything from syntax, definitions, and the underlying structure of expressions to efficient coding, working with various data structures, and even developing packages.

This study group will cover material from our Programming Fundamentals and Practical Programming courses, as well as provide attendees a first look at Programming and Development, the upcoming third and final course in the Programming Proficiency course sequence. Our intent is to provide a setting for this material which not only reaps the benefits of our Daily Study Groups'... well, group nature, but also spreads this material out over two weeks for those who cannot commit to the three-hour blocks required by these courses in their natural habitat.

This study groups aims to get you up and running with Wolfram Language, and as such no prior Wolfram Language or programming experience is necessary.

REGISTER HERE.

We look forward to seeing you there!

enter image description here

POSTED BY: Arben Kalziqi
302 Replies

Hi folks! We've been enjoying your Level 2 certification submissions so far. If you're curious about whether an idea you have would be fit to submit, please feel free to ask in this thread. (If you have technical questions, however, please wait for the next Programming Proficiency Office Hour session, which is currently scheduled for July 25.)

POSTED BY: Arben Kalziqi

Hi Arben,

Thank you for the quiz update.

Problem 7 is broken: none of the choices yields a correct answer. I know which answer I like best though, teehee!

Lori

POSTED BY: Lori Johnson

Thanks for pointing this out, Lori! When I updated the question, the number of answer choices changed and messed up the key—but I'd failed to notice it. It should be fixed soon.

POSTED BY: Arben Kalziqi

Thank you, Arben!

I hope you like my function. I'm still adding to it!

POSTED BY: Lori Johnson

Could you please advise if this program would be suitable for me if I only know how to set up and configure development environments and have just started learning programming languages?

POSTED BY: Ellis Miller
Posted 11 months ago

This course may not be the place to start. If I were starting today, I'd take the Elementary Introduction to the Wolfram Language Interactive Course. This is a big course that covers a lot of different areas of programming and the Wolfram Language. Work all the exercises. It may take several months to get through it, but you'll be left with a good fundamental knowledge of the language after completing. The course text is also available as a physical book, but I don't think the book is the best way to learn this material. Even if you get the book, going through the examples and quizzes online will be required. If your learning style is different and you do get the book, make sure you get the Third Edition. Also, the content of the book is available for free online (follow a link on the book link above).

Get in the habit of looking through the Wolfram Language Reference available online. Notice that you can have a bunch of windows open simultaneously into Wolfram Language code and documentation. You can even do "open frame in new tab" if you need more real estate in one of the sub-windows of the EIWL course. Most importantly, have fun! Write original code about things you know and things you're interested in.

POSTED BY: Phil Earnhardt

Understood, thank you for the advice. Special thanks for "Most importantly, have fun! Write original code about things you know and things you're interested in."

POSTED BY: Ellis Miller
Posted 11 months ago

Replacement rules.

{4, -2, 3.14, 9, -25, 16} /. x_ /; x > 0 && IntegerQ[x] :> Sqrt[x] from the lesson I get.

But I get stuck with the following :

listA= {{a, b, a}, {b, a, a}, {a, b, a, b}, {a, b, b, a, a}, {b, a, b, a}, {b, b, a}, {a, b, a, b}, {b, a, b, a, b,},{ a, a, a, a}}

listA /. {a -> b, b -> a}. This is no problem

But now I want the replacement ONLY to apply to the sublists that start with a ‘b’.

I tried with quite some different ways, but all seem to fail :

listA /. {a -> b, b -> a} /; _First == b.
I get : ReplaceAll::reps: {{a->b,b->a}/;_First==b} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

I tried with a pure function and got nowhere.

Finally, this inelegant creature at least works.

Table[If[SameQ[listA[[n, 1]], b], listA[[n]] /. {a -> b, b -> a}, listA[[n]]], {n, 1, Length[listA]}]

How could I do I do it more ‘Wolfram’ style? If possible, show me how to do it with a pure function as well.

Thanks for your suggestions.

POSTED BY: B. Cornas
Posted 11 months ago

I would do something like this

Cases[listA, x_List /; First[x] == b]

{{b, a, a}, {b, a, b, a}, {b, b, a}, {b, a, b, a, b}}

Cases[listA, x_List /; First[x] == b] /. {a -> b, b -> a}

{{a, b, b}, {a, b, a, b}, {a, a, b}, {a, b, a, b, a}}

POSTED BY: Doug Beveridge
Posted 11 months ago

Thanks for your suggestion, Doug.

I might not have been too clear in my question. But actually I need to get the whole listA back, with only the sublists starting with 'b' changed. But in the sublists that are changed, all element should change.

So sublist {b, a a,b} should become {a,b,b,a}. My apology if I was not clear enough. And for the complete ListA =

{{a, b, a}, {b, a, a}, {a, b, a, b}, {a, b, b, a, a}, {b, a, b, a}, {b, b, a}, {a, b, a, b}, {b, a, b, a, b},{ a, a, a, a}} ,

the should get the result :

{{a, b, a}, {a, b, b}, {a, b, a, b}, {a, b, b, a, a}, {a,b,a,b}, {a,a,b}, {a, b, a, b}, {a,b,a,b,a},{ a, a, a, a}}

POSTED BY: B. Cornas
Posted 11 months ago

blank

POSTED BY: Doug Beveridge
Posted 11 months ago

OK

listA /. x_List /; First[x] == b :> ReplaceAll[x , {a -> b, b -> a}]

{{a, b, a}, {a, b, b}, {a, b, a, b}, {a, b, b, a, a}, {a, b, a, b}, {a, a, b}, {a, b, a, b}, {a, b, a, b, a}, {a, a, a, a}}

POSTED BY: Doug Beveridge
Posted 11 months ago

Thanks Doug. Works great.

I wonderful (and sometimes confusing) to see in how many different ways something can be coded in Wolfram.

POSTED BY: B. Cornas
Posted 11 months ago

Thats why I loved this course by Arben . I suddenly saw things from many angles and it started to make more sense .

eg

f[p_ /; (IntegerQ[p] && p > 0)] := p f[p - 1]

f[p_] := p f[p - 1] /; Positive[p] && IntegerQ[p]

f[p_Integer?Positive] := p f[p - 1]

f[p_?(IntegerQ[#] && Positive[#] &)] := p f[p - 1]
POSTED BY: Doug Beveridge
Posted 11 months ago

Yes but it is still confusing

listA /. x_List /; First[x] == b :> ReplaceAll[x , {a -> b, b -> a}]

{{a, b, a}, {a, b, b}, {a, b, a, b}, {a, b, b, a, a}, {a, b, a, 
  b}, {a, a, b}, {a, b, a, b}, {a, b, a, b, a}, {a, a, a, a}}

works
but

listA /. x_List /; First[x] == b :> x /. {a -> b, b -> a}

{{b, a, b}, {a, b, b}, {b, a, b, a}, {b, a, a, b, b}, {a, b, a, 
  b}, {a, a, b}, {b, a, b, a}, {a, b, a, b, a}, {b, b, b, b}}

does not .......

Maybe Arben can tell us why ?????

POSTED BY: Doug Beveridge

I think it's just order of operations/priority stuff—if you use parentheses like you see in my other post, it works just fine. I didn't actually test it, just wrote it how I figured it was most likely to work!

POSTED BY: Arben Kalziqi
Posted 11 months ago

Thanks Arbin

Yes it is the Parenthesis (good to know )

listA /. x_List /; First[x] == b :> (x /. {a -> b, b -> a})

{{a, b, a}, {a, b, b}, {a, b, a, b}, {a, b, b, a, a}, {a, b, a, 
  b}, {a, a, b}, {a, b, a, b}, {a, b, a, b, a}, {a, a, a, a}}
POSTED BY: Doug Beveridge
Posted 11 months ago

Ditto. Arben gives new and very insightful perspectives on the material. He teaches on many levels simultaneous and his examples are really exemplary. A very complete teacher, which is quite rare.

POSTED BY: B. Cornas
Posted 11 months ago

The issue is here:

/; _First

The /; means that you write some test afterward—not only is _First not a component of a test, but it's not the correct pattern syntax. Recall that what follows a Blank (_) should be a head to be matched; i.e. you can't put an arbitrary function there and take it to be acting on whatever the blank is.

If you have

listA= {{a, b, a}, {b, a, a}, {a, b, a, b}, {a, b, b, a, a}, {b, a, b, a}, {b, b, a}, {a, b, a, b}, {b, a, b, a, b},{ a, a, a, a}} (*i removed the errant comma*)

and want to do {a -> b, b -> a} on any sublist that starts with b, you could do something like

listA /. l_List /; First[l] == b :> (l /. {a -> b, b -> a})

if you wanted to use Condition. Better yet, just match the pattern directly:

listA /. {b, rest__} :> ({b, rest} /. {a -> b, b -> a})
POSTED BY: Updating Name

(this is arben.)

POSTED BY: Arben Kalziqi
Posted 11 months ago

Hi Updating Name (Rohit?),

I suspected that I did not use First correctly :-)

Your solution works excellent. Also if I nest the sublists deeper and irregular (different nesting levels). That is great.

Do I understand it correctly, if I say :

{b, rest__} looks at all the innermost sublists and if there is such a sublist that starts with a 'b' and has one or more elements, then the replacement takes place?

Thanks again for your valuable help,

Best, Bert

POSTED BY: B. Cornas

yes, exactly—if you have a list that starts with b and has one more or elements after the b, then what I wrote will work. If you want to include {b} alone, you have the exact right idea with ___/BlankNullSequence.

POSTED BY: Arben Kalziqi
Posted 11 months ago

You reply faster than I can edit. Wow :-)

POSTED BY: B. Cornas

Arben, New general question -- do you know what is going on with Demonstrations? In anticipation of getting my Wolfram Level 2 certificate, I have submitted a demonstration, but have heard nothing back. The formal submittal process seems to be broken, and attaching the Demonstration notebook to an email (to the Wolfram Demonstrations Group) didn't seem to elicit a response either. I have submitted a question on the matter to Wolfram Tech Support, but have heard nothing back (yet). Can anyone tell me if the Demonstrations project is still active? Finally, will time run out on my Level 2 certificate before the issues are resolved? Sorry to bother you with this, but I would like to know what is going on just to ease my mind that I have done all I can. Thanks, Mike

POSTED BY: Michael Ulrey

Hey Mike, we'll get back to you soon about this. In the meantime, please don't worry about any timeline issues—as far as we're concerned, you've submitted your project within the deadline and that's that.

POSTED BY: Arben Kalziqi

Arben, I still have not heard anything about the Level 2 certificate. Maybe it just takes awhile, and I can understand that. However, I'm afraid I may have gummed up the works when trying to pay the fee for Level 2 using the web payment software. I got an "unexpected error" message, and the software then interpreted the discount code as my payment (several times). Christine helped me get my money back, but this left me wondering if the system thinks I have not paid at this point. So I just want to make sure that I'm still in the queue to get a certificate, or if I need to do something more. Thanks.

P.S. In the meantime, an attendance certificate for the AI webinar (which I took before the Programming Proficiency course) showed up on my LinkedIn account. I'm worried that the system thinks this is what I was trying to get credit for, and has now dropped the Level 2 request (associated with the Programming Proficiency course and subsequent Demonstration submittal).

POSTED BY: Michael Ulrey

Hey Michael—I'm sorry about that! I finished grading it 2-3 weeks ago; I'm not sure what got blocked up in the process but we're on it. (Spoiler: you passed)

Edit: you should have it later today.

POSTED BY: Arben Kalziqi

Thanks!

POSTED BY: Michael Ulrey
Posted 11 months ago

Right, thanks Arben :-)

I just got my first connection through a chat Nb with chatGPT and asked the same question. After two misses, and restating my question more precise (and partly double), I gotv a working answer :

Map[If[First[#] === b, # /. {a -> b, b -> a}, #] &, listA]

It's nice to see it work, although your solution is more refined, I think, and probably faster :-)

But the A.I. solution shows me again the pure function, which I understand in theory, but in practice I often seem to do it wrong. It will come, some day.

Also, in the If statement (which I also used, I first used == instead of what I should have done : ===. I dodged my error by using SameQ[]. So I think this A.I. coding help can be useful in the learning process.

POSTED BY: B. Cornas

Yeah, it can definitely be useful for exploring—it can also definitely be a little frustrating for reasons you touch upon, but so it goes :)

POSTED BY: Arben Kalziqi
Posted 11 months ago

Arben, I tried using Timing[...] and AbsoluteTiming [...] on 3 different instructions to accomplish the same thing: Power, an anonymous function using Keys, and an anonymous function using indexing. I used a large enough list of associations so that Timing was non-zero. All three had Timing between about 2.1 and 2.8 seconds, and AbsoluteTiming between about 3.7 and 3.9 seconds. I ran this in Mathematica 14 on an HP Envy running Windows 11 Home 64-bit OS. My notebook is attached as file TimingExample_1mar24.nb .

I expected Power to be clearly faster but it wasn't. Please explain these timing results.

POSTED BY: Gerald Dorfman
Posted 11 months ago

give me your timing for a much smaller problem .

{<|"a" -> 1, "b" -> 2|>, <|"a" -> 3, "b" -> 4|>, <|"a" -> 5, "b" -> 6|>}

POSTED BY: Doug Beveridge
Posted 11 months ago

Using

shortListOfAssoc = {<|"a" -> 1, "b" -> 2|>, <|"a" -> 3, "b" -> 4|>, <|    "a" -> 5, "b" -> 6|>}; 

I added Timing, AbsoluteTiming, and Repeated timing to the file I uploaded before, TimingExample_1mar24,nb , which is attached. (I also added RepeatedTiming for listOfAssoc that I ran previously.) My respective results for shortListOfAssoc using Power, anonymous function with tags, and anonymous function with indices are as follows:

Timing: all three were 0.

AbsoluteTiming: 0.0000124, 0.0000111, 0.0000101

RepeatedTiming: 1.3700510^-6, 2.1609110^-6, 4.3709*10^-6

POSTED BY: Gerald Dorfman

Looking into this and will let you know what I find. Something interesting is that the timing is pretty nonlinear even for an operation like this, so I expect there's something going on with how the values are stored under the hoot.

POSTED BY: Arben Kalziqi
Posted 11 months ago

Hi Arben,

I could not properly formulate my question in The Office Hours Session as I had only joined in at the very end (a miscalculation on my part). So thank you for suggesting I pose my question here.

I am trying to make a kind o’f Rhythm Evolver’ by means of an Evolutionary process. One thing is that I need to detect the degree of ‘regularity’ in a rhythm as a fitness score parameter.

This way I also try to find out if Nesting as a ‘regularity’ in music is easily, or at all recognised by listeners. Nesting is the most complicated and hidden regularity. Repetitions are much easier recognised.

Let’s just talk about just one line (one rhythm instrument, e.g. Kick drum), as I think it is already difficult enough.

A hit is 1, no hit is 0.

  1. I have already been given a way to detect ‘Repetition’, ‘Symmetry’ and ‘Permutations’ of parts (also here in the Community :-)

Now I am looking for a way to detect ‘Nesting’.

E.g. The following 3 parts : {1,0,0,1} {1,0,0,1,0,1,1,0} {1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1}
all come from the nesting Rule : 1->{1,0}. and 0-> {0,1} starting with {1,0} and applied respectively 1x, 2x and 3x.

I want to go the other way, and see if in a rhythm line, that has been evolved , there is any sort of Nesting as regularity. Not with these specific rules and specific initial condition. I want to detect ANY Nesting (any rules, any initial condition).

So, given the line { 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1}, I should detect that the bold part (1, 0, 0, 0, 1, 1, 0, 1, 1) is a nested part from:

               Initial conditions {1,0} with the rules : {1 -> {0, 1, 1}, 0 -> {1, 0, 0}}

It is no really important that I detect what rules and which initial condition, but I want to detect which part of my Rhythm Line is a Nested part in any form.

I am not sure if it is possible, without trying all the rules. This due Stephen Wolfram’s ‘Computational Irreducibility’ .

What are your thoughts?

Thanks, Bert

POSTED BY: B. Cornas

Hi Bert—hmm... my first thought is that in general your feeling about computational irreducibility is correct. However, if the cases are 1:1 like you've shown so far (which I think you say that they aren't), then you can certainly do it a few ways.

  • Less elegant but probably most efficient is to partition your sequence up by rule size—if the nesting creates three numbers, you can just partition a result into blocks of 3 and reverse the nesting rules to get back to where you started.
  • More elegant but less efficient (because it requires pattern-matching that could be rather general) would be to use SequenceReplace.

But again, if the rules aren't 1:1 you're going to run into issues. If they output different lengths, you'll need to use SequenceCases and you may be able to work backwards from there.

POSTED BY: Arben Kalziqi
Posted 11 months ago

Thanks Arben. Do you mean by "if the cases are 1:1 . . ." that the rules are of equal length?

So {1->{1,0,1} and 0->{0,0,1}} is 1:1 and {1->{1,0,1} and 0->{0,1}} is Not?

Reverse the nesting rules is not quite possible, I guess, as I do not know which rules might have been used. Also, the nesting might be 2 or 3 deep, so I do not know the length to parse. It feels a bit like backwards running a C.A., which is possible in some cases, but not very often.

Checking for repetitions in a rhythm line is easy, but this Nesting looks like a different animal :-)

As the computation comes into a repeated process of measuring the amount of Nesting in a rhythm ( so thousands of these detection measurements), it might be an idea to create a lookUp table with all the possible nestings for two elements (0 and 1). If a take as a max of number of initial elements, as well max number of elements in a rule to be 3 (which I think servers my purpose) then there would be 14 possible initial conditions and 12 rules for 0 and twelve rules for 1. As these rules are 'mirrored, I need only to take into account half of them. Then I create the lookup table for all Nestings from level 1 to say 3, which should be enough. From there on I could use SequenceCases or SequencePositions.

This will still leave the challenge for detecting Nesting in a complete rhythm, where I use 16 possible values for the possible simultaneous occurances of hits from 4 instruments together. This will explode with lookUp tables, I am afraid.

Best, Bert

POSTED BY: B. Cornas

By 1:1 I mean it in the sense of functions—as in, "in some given sequence, can any one particular output subsequence only be generated by one input?" If you don't have that, I don't think it's feasible.

POSTED BY: Arben Kalziqi

What is the deadline for using the Level 2 discount code I received? (I took the first WSG24 this year)

I have a project idea but haven't had much time since the course ended and probably won't for a couple weeks longer.

POSTED BY: David Snyder

@David Snyder, the $50 promo offer is good through June 30, 2024.

POSTED BY: Jamie Peterson

Never mind, (content removed)

POSTED BY: Carl Hahn
Posted 11 months ago

I am looking for a way to do an operation inside a nested List. The nesting is 4 deep and the inner-lists are of unequal length.

E.g. listA = {{{{1, 2}, {3, 4}}, {{5, 8}, {9, 12}, {14, 17}}}, {{{11, 13}, {15, 17}}, {{18, 20}, {22, 24}}, {{26, 31}}}}

I want to subtract the first number form second number in each sub-list. The nesting needs to be preserved.

So the result should be : {{{{1}, {1}}, {{3}, {3}, {3}}}, {{{2}, {2}}, {{2}, {2}},{{5}}}}

I tried with Map at level{3} and {4} but it did not work. Or with a pure function, also no dice. Also Table. I tried quite a lot of things, but the deep nesting is throwing a wrench into my engine.

POSTED BY: B. Cornas

Today's lecture should do you well :).

In[53]:= 
listA = {{{{1, 2}, {3, 4}}, {{5, 8}, {9, 12}, {14, 17}}}, {{{11, 13}, {15, 17}}, {{18, 20}, {22, 24}}, {{26, 31}}}};
listA /. {x_Integer, y_Integer} :> {y - x}

Out[54]= {{{{1}, {1}}, {{3}, {3}, {3}}}, {{{2}, {2}}, {{2}, {2}}, {{5}}}}

More to the style you'd imagined—and faster for a large list—is:

In[57]:= Map[{-Subtract @@ #} &, listA, {-2}]

Out[57]= {{{{1}, {1}}, {{3}, {3}, {3}}}, {{{2}, {2}}, {{2}, {2}}, {{5}}}}

And the best version, I think:

``` In[69]:= Apply[{#2 - #1} &, listA, {-2}]

Out[69]= {{{{1}, {1}}, {{3}, {3}, {3}}}, {{{2}, {2}}, {{2}, {2}}, {{5}}}}```

POSTED BY: Arben Kalziqi
Posted 11 months ago

Wow, even after what must be an exhausting session for you as well, I get an immediate answer. Truly amazing :-)

  1. I tried also with Rules, but used a too wide a pattern (I cannot put it here as the 'underscore' disappears in the post. I get my mistake.
  2. The map example I have to study tomorrow. I am also tired now
  3. In Apply[{#2 - #1} &, listA, {-2}]. I missed the function at first, but of course it is the Subtract (the -). So I rewrote the function :

    Apply[Subtract[#2, #1] &, listA, {-2}]
    

and strangely enough the innermost level is gone, which by the way is excellent for me in this case. So I get now {{{1, 1}, {3, 3, 3}}, {{2, 2}, {2, 2}, {5}}}

Why is there a difference with Apply[{#2 - #1} &, listA, {-2}]?
I looked at FullForm and Trace, but could not deduct why it is different.

Thanks a million, Arben,

Best, Bert

POSTED BY: B. Cornas

Hi Bert—I thought you wanted the extra braces still for some reason, so I had added them back in! They disappear with Apply because Subtract (and indeed -) wants two arguments provided as a sequence, not as a list—that's why we use Apply, because Apply[Subtract,{a,b}]===Subtract[a,b]. Hence, you can see the difference between Apply[Subtract[#2,#1]&,...] and Apply[{Subtract[#2,#1]}&,...].

I see why writing the Subtract out is helpful for clarity, though I would say that getting an intuitive sense of what something like #2-#1&@@ is really doing is indispensable to working efficiently with Apply and its siblings. I would say you can think of it as "an operation which strips out the second and first arguments of ANY structure and gives me their difference". It works on lists, it works on sums and products, it works on any arbitrary g[a,b] with the action that #2-#1&@@g[a,b]===b-a.

Also, you can type code between backticks here, like `hello_` in order to prevent any unwanted markdown formatting. You can start a new line with 3 backticks, press enter, then type/paste code and do another new line with 3 backticks in order to get the formatted boxes you see in my previous reply.

POSTED BY: Arben Kalziqi
Posted 11 months ago

Great Arben, I get it.

So, to get rid of the unwanted brackets, I could do :

Apply[#2 - #1 &, listA, {-2}] or Apply[#2 - #1 &, listA, {3}]

Both give the same result. Is there a hidden advantage in using levels counting from the back {-2} ?

To get my end result in this, I have :

Total[Apply[#2 - #1 &, listA, {3}], {3}]
This sums the partial results and that is what I need to continue.

Now the Map from yesterday.

Map[Subtract @@ # &, listA, {-2}]

I think I understand it, but find it hard to come up with myself. I tried to rewrite it without the 'shorthand', just to get a grip on it.

`Map[Apply[Subtract[#[[2]], #[[1]]] &, listA], {-2}]

Map[Apply[Subtract[#[[2]], #[[1]]] &, listA, {-2}]]`

Both are not correct. It looks as if the level {-2} is taken only after the Apply is done. Still , the second example, where I moved the level-spec into the Apply, it still does not work.

I am getting closer to understanding it, but I am not quite there, I am afraid.

Arben, your help is really great :-)

Best, Bert

POSTED BY: B. Cornas

Since you're Apply-ing, you get rid of the List structure. In that context, what does #[[2]] or #[[1]] mean?

POSTED BY: Arben Kalziqi
Posted 11 months ago

...

POSTED BY: lara wag
Posted 11 months ago

Suppose there is an external database or other data source. Unfortunately, in this external data source, the keys are in lower case with underscores ("snake_case"), e.g. company_name. To work properly in Wolfram Language, the keys must be in camel case, e.g. companyName.

Here is an example that works on a List of Associations:

AssociationThread[
   StringReplace[Keys[#], 
     MapApply[Rule, 
      Transpose@{"_" <> # & /@ Alphabet[], 
        ToUpperCase[Alphabet[]]}]] -> Values[#]] & /@ data

To be honest, from my perspective it looks ugly, especially the "Transpose" part. Any ideas on how to make this transformation more concise?

... or is there a built-in function for this that I don't know about? I saw this resource function https://resources.wolframcloud.com/FunctionRepository/resources/ToCamelCase/, but I wasn't able to make it run in this "key of association" problem.

Notebook with sample data attached.

POSTED BY: lara wag

Hi Lara—keys in an association can be basically whatever you want, and certainly be in the form of "company_name" for example. If you need to access them via "slot" notation, you can just wrap them in quotes:

In[280]:= #"company_name" &@<|"company_name" -> 2|>

Out[280]= 2
POSTED BY: Arben Kalziqi
Posted 11 months ago

Thank you, Arben, for your super-fast reply.

Interesting - so it works with quotation marks. - Thank you!

POSTED BY: lara wag
Posted 11 months ago

Hi Lara,

An easier way to rename the keys is to use KeyMap.

data // Map[
  KeyMap[StringReplace[{"_id" -> "ID", 
                        "id" -> "ID",
                        "_" ~~ c : LetterCharacter :> ToUpperCase@c}]]]
POSTED BY: Rohit Namjoshi
Posted 11 months ago

Thank you very much, R, impressive! I was looking for something like that.

POSTED BY: lara wag

Hi Arben;

I remember you covering in one of the lectures a technique of applying MapAll (/.) before evaluating the expression as opposed to after the expression is evaluated. However, I cannot remember the way you formatted the function. Can you please show me one more time? The example below shows the values being assigned after the function is evaluated, which is not what I want. What I want are the values of Sin[t], Cos[t], Tan[t] to be assigned to x, y, z before any other functions are evaluated.

Thanks,

Mitch Sandlin

D[Log[x^2 + y^2 + z^2], t] /. {x -> Sin[t], y -> Cos[t], z -> Tan[t]}
POSTED BY: Mitchell Sandlin

I think you just do exactly what you said you want to do, i.e. assign the variables before you take the derivative:

D[
Log[x^2 + y^2 + z^2] /. {x -> Sin[t], y -> Cos[t], z -> Tan[t]}
, t]

Or even before you take the Log, but I think that gives you the same answer:

D[Log[(x^2 + y^2 + z^2) /. {x -> Sin[t], y -> Cos[t], z -> Tan[t]}],
  t]
POSTED BY: Carl Hahn

Hi Mitchell

/. is ReplaceAll, not MapAll. I don't recall what Arben showed but here are a couple of ways

Unevaluated[D[Log[x^2 + y^2 + z^2], t]] /. {x -> Sin[t], y -> Cos[t], z -> Tan[t]}

Hold[D[Log[x^2 + y^2 + z^2], t]] /. {x -> Sin[t], y -> Cos[t], z -> Tan[t]} // ReleaseHold

(* (2 Sec[t]^2 Tan[t])/(Cos[t]^2 + Sin[t]^2 + Tan[t]^2) *)
POSTED BY: Rohit Namjoshi

Take Rohit's answer, but also note that if you were to write x'[t] and so on—that is, explicitly note the time dependence—D will take those derivatives symbolically and you can plug in values for the time-dependent functions after the fact, at which point the derivatives will be evaluated.

POSTED BY: Arben Kalziqi

Arben, I don't think I understand what you just said (a rare thing...). How would you re-write the expression?

I liked the elegance of the "Hold" and "Release Hold" solution, but only because it's explicit. However, I do get the same answer by using ReplaceAll within the brackets of the Derivative forcing it to happen before the derivative is taken. I've noticed in other people's examples that you can stick the /. operation all over the place. What is wrong with that?

(my own answer would be that if you are writing longer code, it gets hard to read and understand - I'm just asking a more generic question about WL grammar rules) Carl

POSTED BY: Carl Hahn
Posted 11 months ago

I've noticed in other people's examples that you can stick the /. operation all over the place. What is wrong with that? (my own answer would be that if you are writing longer code, it gets hard to read and understand - I'm just asking a more generic question about WL grammar rules) Carl

My suggestion is to use the standard functional call (ReplaceAll[], etc.) until you thoroughly understand them. You should always -- always -- be able to see and say the long form when the shortcut is being used. IMHO, it's a big problem to use shortcuts if you don't always have the formal name of the function call on the tip of your tongue. Note: even things like _x have a standard form: Blank[x]. Computers have the ability to expand any shortcut within a microsecond; we should be ability to translate either way with a similar amount of minimal computational overhead.

You want to be able to rattle off a spell with the ease of Hermione Granger and avoid the clumsiness of Neville Longbottom. You should have no "lost in translation" moments between a shortcut and its normal form.

I kinda wish that the Notebook editor would have a means of flipping something to its normal form (and vice versa). I also wish that the Help documentation would always show both forms on examples; it tends to be prejudiced towards the shortcuts. I like to verbalize the normal form when I look up something in the docs.

POSTED BY: Phil Earnhardt
Posted 11 months ago

That's a fine and helpful tip for the newbies to the Language. I'm having to constantly look up and flip over to several views or points. The Docs but There are many "points" in the docs to look at. I have to reference a LOT. So that's one thing I'm learning. It's not enough just to read one part.

I often remind myself. I'm doing it wrong! What am I missing? What can I not see?

Does anyone have any experience with Reeturn[] I'm not able to use it on TraceDialog. With this error message.

"TraceDialog::dgbgn: Entering Dialog; use Return[] to exit." I didn't get a dialog and my process was stuck running. I had to close the window to get it to stop.

Cheers.

POSTED BY: Zachary Wertz
Posted 1 year ago

Will there be another one of these classes?

POSTED BY: Paul Nielan
Posted 1 year ago

Will there be another one of these classes?

POSTED BY: Paul Nielan
Posted 1 year ago

I'm having problems understanding number three which works with Set Delayed Rule and Blank.

I couldn't catch on C++ a long time ago in college. Maybe that's why I don't understand this concept. Object orientated programming. My problem seems that there's too much overlap in definitions. There's no similarly to compare it to. The concept is Invisible.

There's a few things happening with the blank, and the "f" and the "x" those are all condensed things or overlapping definitions. Left to right replacement. Got that. what is "f" and "x" or x or x you could call them "Head" or a function. of the [ ]. I'm struggling to find an explanation of what x or x is Now I do understand that is is just a blank to be filled in but the x or f is a distraction. why not just _ without f or x that make more sense.

Now I tried to make this work and nope. nothing works. Is it because of the Delayed rule? That's a new idea. I guess I haven't tested that out yet. changing :> to -> instead. I can try that next. I don't understand what to do to get the replacement happening it seems that it should be just happening if there are blanks in the right place but maybe it's because of the Delayed rule. I tried changing the delay to a rule and it's the same. I used Trace. With Trace I just get {} and without Trace I get the same out as I put in f[1,2,3] I don't know if the rule is even working or able to work on f[1,2,3] that's my problem I don't see how the problem is applied to f[1,2,3] it seems it is not.

POSTED BY: Zachary Wertz
Posted 1 year ago

I found Richard J. Gaylord's video on youtube. It's a great video and I saw it a while back. The first five minutes of the video or really the first minute of the video when he starts his lecture has got me into the invisible part and it's a great help to understand the structure of wolfram language. I hope to find and learn how to read the Docs better.

I'm doing FullForm the rhs of number three which is what I was talking about. It's been helping so far. I still have to learn the Pattern. Like I said it's confusing how the new vocabulary is used with seeming overlapping meanings. This first minute of the video has been helpful to find what to look for.

Head and what follows? and how WF evaluates it maybe old news for some of if you. For me who I haven't been using the language for a long time regularly it's a big help. I'm not done yet.

POSTED BY: Zachary Wertz
Posted 1 year ago

Thanks for the useful reference. Fills in some of the blanks in Arden's excellent lectures. I always like several points of view.

POSTED BY: Steven Brawer

This is a nice talk! Glad to see that I've naturally settled on many of the same explanations as Richard gives here :)

POSTED BY: Arben Kalziqi
Posted 1 year ago

I worked on a exercise to from EIWL which was just adding up a list and I wanted to do it with Plus, Range. I failed and spent a hour learning. Then came back to it.

Recap. I was working on trying to use a symbol to do the adding or multiplying with @@ I could not get it to work. I could not figure out what was happening. I tried a lot of things. Nothing seemed to work. I looked up Trace, TreeForm, and a whatever I came across. I played around with the documentation changing the code around.

I figured out how to do it, after my nap. Checking with TreeForm told me the "path" of the code that I could not see. Checking the documentation on how to properly write it over and over. I could see that Plus was not getting worked on the List. So I knew I wrote it wrong.

The hour of work was not wasted. From that hour of work. That is how I got the code to be "visible". I worked with TreeForm and the documentation trying out Map, ThreadMap, Funny because I was using Apply in the first place I just wrote it wrong.

I found a you-tube video on Lists that was helpful. I also read some tutorials on how to properly write wolfram code. I read the Filled in Notebooks, and whatever I came across. So it was a bunch of hopping around sources then a long break and back to finally finding the correct way to write it. It helps that I realize that I'm trying to write it the way I think it works and that is wrong. I need to find how it is supposed to be written.

Merry coding to everyone.

POSTED BY: Zachary Wertz

Hi Arben;

As an aside, I came across something the other day that I did not understand but figured you would.

I understand what a Derivative (D) and an Implicit Derivative (ImplicitD) are, but what in the world is a Total Derivative (Dt). In all my years of math, I just came across this thing called a Total Derivative and hoped you could shed some light.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 1 year ago

Hey Mitch! I also remember coming to this comparatively late in my math career (though frankly I'm sure it was in our diff eq class and I missed it because I was boooooored). As is indicated by Steve, probably the easiest inroad to the idea of the total derivative is the chain rule. To that end, check out the corresponding lesson from our multivariable calculus MOOC (including lesson notebook, lecture video, and exercises with solutions)—it's lesson 15 here.

POSTED BY: Arben Kalziqi

On the L1 exam, do I take a list shown as {1, 2, 3, a, b, c} verbatim or am I to interpret the list as {1, 2, 3, "a", "b", "c"}? I wasn't sure since the color coding as done in Mathematica didn't carry over to the exam.

POSTED BY: David Snyder

Definitely verbatim. If you think that there is an error, be sure to tell Arben :-)

POSTED BY: Lori Johnson

(confirming here for, well, official confirmation.)

POSTED BY: Arben Kalziqi
Posted 1 year ago

I have a question about pattern matching.

  1. Cases[{1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0}, {0, 1, 0}] This returns empty. I know why :
  2. Cases[{1, 1, 0, 1, 1, 0, 1, 0, 0, 1, {0, 1, 0}, 1, 0, 0}, {0, 1, 0}] This returns {0,1,0}

So the List delimiters {} make that example 1 does not work.

I tried Cases[{1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0}, {_ _ , 0, 1, 0, _ _ }]
Code should show { underscore 3x , 0,1,0, underscore 3x } unfortunately but comes out different in the post (only 2 underscores are shown). This also does not give a correct result but {}. I was surprised that this is wrong :-)

How should I approach example one, so that I get the 4 times 0,1,0 as a result? And how do I get the starting positions of each 0,1,0 ? (so here : {6,9,11,13}

POSTED BY: B. Cornas

Use Partition. It can be done in one instruction, but to make it clearer, I break it down:

lst = {1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0};

par = Partition[lst, 3, 1]

Cases[par, {0, 1, 0}]
POSTED BY: Gerald Dorfman
Posted 1 year ago

Thanks Gerald, I understand your way. I see that the '1' in the Partition[lst, 3, 1] is needed. I also need to get the positions and can get those by Position[par,{0,1,0}]. The result is correct. Your way works also good if the list starts or ends with the wanted pattern.

In a broader context, I need to test many more 'regularities'. Imagine the lst = {1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0} is a rhythm where 1 stands for a hit and 0 for a silence. I want to get all the regularities from this rhythm line. So I would need to test also parts with length 2, length 4, etc. And I need to do it fast (testing many rhythms). So maybe there is a way to avoid the partitioning, which would have to be different for different lengths of search lists.

This checks for 'repetitions'. How could I test for mirror symmetry? E.g. {0,0,0,1,0,1,1,0,1}. here 1,0,1 is a symmetry as well as 1,0,1,1,0,1 How could I test for Permutations of the pattern? E.g. {1,0,1,x,x,x,x 0,1,1,x,x,x,x,1,1,0}. here are 3 permutations of {1,0,1} present. How to detect them?

POSTED BY: B. Cornas

In attached file Symmetries.nb , I've written and executed a module to find the symmetries you are interested in and a function to count the number of subsequences in an ordered list of length at least 2.

The module creates a random list of zeros and ones of length at least 2, finds all its ordered subsequences of length at least 2, and lists all its symmetric subsequences. I assume that subsequences of length 1 are of no interest because they are trivially symmetric.

The simple function counts the number of subsequences of length 2 or more from a list of length at least 2. The code uses the function to print a table of the counts for lists of length 2 through 15.

Although I compute the number of subsequences as a sum, it's easy to derive the formula by just evaluating the sum. Given a list (i.e., an ordered list) of length n, the number of subsequences of it of length k is just the number of leftmost positions of sequences of length k, namely n-(k-1) = (n+1) - k. Now, sum for k = 2 to n. Since (n+1) is a constant, the sum of the first term is (n-1)(n+1) = n^2 - 1. The sum of the second term is just 1 less than the sum of the first n integers, namely n(n+1)/2 - 1 = (n^2)/2 + n/2 -1. So the number of subsequences of length at least 2 of a list of length n is (n^2 - 1) - ((n^2)/2 + n/2 -1) = ((n^2)/2 - n/2 = n(n-1)/2. So, instead of using the sum to define the function numSequences , one could define it as numSequences[n_Integer /; n >= 2] := n(n-1)/2 . I used the sum just to make the code easy to understand.

Attachments:
POSTED BY: Gerald Dorfman
Posted 1 year ago

Hi Gerald, thanks for your help. I just downloaded your example Nb and will look into it. I'll come back on it later.

POSTED BY: B. Cornas
Posted 1 year ago

I worked through your Nb. Thanks for the work you've done. It works well and I learned a thing or two, which I can apply on other places in my project.

Really appreciate your help, as well as Rohit's.

POSTED BY: B. Cornas

Here are a couple addenda to the Symmetries.nb file and comments I provided:

(1) A quick derivation for the formula for the number of (ordered) subsequences in an n-sequence (i.e., an ordered sequence of length n): Call the n-sequence "seq", and number its positions from left to right 1, 2, ..., n. The subsequences are uniquely defined by their leftmost and rightmost positions. Since we want subsequences of length at least 2, the choices for the rightmost position are 2, ..., n. If k is the choice for the rightmost position, then the choices for the leftmost position are 1, 2, ..., k-1, so there are k-1 choices for the leftmost position and hence k-1 subsequences with rightmost position k. So, the number of subsequences in an n-sequence is the sum of (k-1) for k = 2, 3, ..., n. That's the same as the sum of the integers from 1 to (n-1), which is just n(n-1)/2. (The formula for the sum of the first m integers is well known. It's just m(m+1)/2.)

(2) Instead of using Cases in file Symmetries.nb, I could have used Select:

    Select[subsequences, (#===Reverse[#])&];

I used Cases to show how to use a pattern, which can also be used for Position.

POSTED BY: Gerald Dorfman
Posted 1 year ago

I am happy to see your explanation for the derivation for the formula for the number of (ordered) subsequences in an n-sequence. Very helpful. I tried Select i.s.o Cases and that works fine as well. I guess that you put the parenthesis around # === Reverse[#] in Select[subSequences, (# === Reverse[#]) &]; for clarity. It also works without them.

Thanks again , Gerald

POSTED BY: B. Cornas

Yes. I put the parentheses around the pure function for clarity. Doing stuff like that was recommended in class. For myself, given how simple that pure function is, I would not have bothered.

POSTED BY: Gerald Dorfman
Posted 1 year ago

I thought so, but a useful practice :-)

POSTED BY: B. Cornas

one quick note here: parentheses are still good for clarity, but we did—in version 13.x for some value of x—introduce something to help here. namely, when you type & after a pure function, it will quickly highlight the function it's "closing" so you can be sure that you have things grouped correctly. (the common case here is when doing something like ColorFunction->#1^2&—you need the parentheses after the -> because otherwise it thinks the pure function to be closed is ColorFunction->#1^2 rather than just #1^2.)

POSTED BY: Arben Kalziqi

I have not run any benchmarks but I suspect that using the built-in PalindromeQ may be faster than # === Reverse[#] &.

POSTED BY: Rohit Namjoshi
Posted 1 year ago

Hi Rohit,

that was my idea as well and I wanted to do some timing tests as soon as I had time. Also the Option 'Overlap' we talked about earlier is very useful for my project.

But the extended explanation of Gerald helped me in another way. I am pretty new to Wolfram language and still have to adapt from Procedural programming, which takes quite a paradigm shift.

POSTED BY: B. Cornas

Use the Sequence* family of functions

list = {1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0}

SequenceCases[list, {0, 1, 0}, Overlaps -> True]

SequencePosition[list, {0, 1, 0}]

Overlaps -> True is the default for SequencePosition which is a little inconsistent

POSTED BY: Rohit Namjoshi
Posted 1 year ago

Great Rohit, this works very well. Thanks.

In which sense is Overlaps -> True inconsistent? I saw in the docs, that SequencePosition has the same Overlaps option. Is it also inconsistent there?

Would you also have some suggestions for the following :

This checks for 'repetitions'. How could I test for mirror symmetry? E.g. {0,0,0,1,0,1,1,0,1}. here 1,0,1 is a symmetry as well as 1,0,1,1,0,1 How could I test for Permutations of the pattern? E.g. {1,0,1,x,x,x,x 0,1,1,x,x,x,x,1,1,0}. here are 3 permutations of {1,0,1} present. How to detect them?

POSTED BY: B. Cornas
Posted 1 year ago

Hi B.

In which sense is Overlaps -> True inconsistent? I saw in the docs, that SequencePosition has the same Overlaps option. Is it also inconsistent there?

What I meant is that the default value of Overlaps is True for SequencePosition and False for SequenceCases. That seems inconsistent to me.

For symmetry something like this?

list = {0, 0, 0, 1, 0, 1, 1, 0, 1}
Subsequences[list, {3, Length@list}] // Select[PalindromeQ]

For permutations generate all of them and test each with SequencePosition?

perms = Permutations[{1, 0, 1}]
list = {1,0,1,x,x,x,x 0,1,1,x,x,x,x,1,1,0}
SequencePosition[list, #] & /@ perms
POSTED BY: Updating Name
Posted 1 year ago

Thanks Rohit, i get the 'inconsistency' and I agree.

Your solutions for Symmetry and Permutations work fine and I can extend on them :-)

POSTED BY: B. Cornas
Posted 1 year ago

Hi Rohit,

I wanted to take your idea a little further, more general, but I run into a snag I do not understand. SequenceCases[pattern1, {0, 1, 0}, Overlaps -> False] from your previous post. This works great :-)

But now to find more general patterns : list={0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1} patternToFind = {x, y, x_} SequenceCases[list, patternToFind, Overlaps -> False]

I get {{1, 1, 1}, {1, 0, 1}, {1, 0, 1}} as result.

Why is the [1,1,1} there? I specified the first and third to be the same, but the second element to be different. I expected to get {1,0,1} and {0,1,0}. The result also misses the {0,1,0}.

Any good ideas?

POSTED BY: Updating Name

Hi B.

In a pattern with a symbol, the symbol is what the match is set to. So {x_, y_, x_} matches something, x is set to that thing, followed by something, y is set to that thing, etc. The fact that the symbol is different does not mean the match has to be different.

MatchQ[{1, 1, 1}, {a_, b_, a_}]
(* True *)

You need to use Condition to ensure they are different

MatchQ[{1, 1, 1}, {a_, b_, a_} /; b != a]
(* False *)

The missing ones are because of Overlaps -> False

SequenceCases[list, {x_, y_, x_} /; x != y, Overlaps -> True]
(* {{1, 0, 1}, {0, 1, 0}, {1, 0, 1}, {1, 0, 1}, {0, 1, 0}} *)

The matching positions

SequencePosition[list, {x_, y_, x_} /; x != y, Overlaps -> True]
(* {{6, 8}, {7, 9}, {8, 10}, {11, 13}, {12, 14}} *)
POSTED BY: Rohit Namjoshi
Posted 1 year ago

Great Rohit, thanks.

I had understood that {x,y,x} was different from {x,x,x} as a pattern .

I had the 'Overlaps -> True' first, but as I did not have x != y , I got about way too much solutions.

Now it works fine :-)

Best , Bert

POSTED BY: B. Cornas

Hi Bert,

They are not the same

MatchQ[{1, 2, 1}, {x_, x_, x_}]
(* False *)

MatchQ[{1, 2, 1}, {x_, y_, x_}]
(* True *)

The first pattern specifies that all elements must be the same. The second specifies that the first and third elements are the same. The second element can be anything, including the same as the first and third.

MatchQ[{1, 1, 1}, {x_, y_, x_}]
(* True *)
POSTED BY: Rohit Namjoshi

Precisely! When I talk about pattern matching, I always talk about x_ as "something—call it x" for exactly this reason.

POSTED BY: Arben Kalziqi
Posted 11 months ago

Rohit & Arben, I get it. Great help. Cheers , Bert

POSTED BY: B. Cornas

Is the 5th question in the level 1 exam :-

"Beginning with data = {{15000, , 89000,, ............"

correct/valid ?

POSTED BY: Doug Beveridge

Ok , it is correct

POSTED BY: Doug Beveridge

Questions are randomly (actually, pseudorandomly) selected from a pool; the odds that any person would have the same 5th question are rather low.

I had a question on my L1 quiz where there were 3 possible answers, plus "all of the above". It turned out that 2 of the 3 were giving the correct response and one was giving a different response; none of the answers could possibly be right. I was running my quiz notebook off of the Wolfram Cloud; that appears to be the reason for the one buggy response. I answered the question as if the function was behaving correctly. I sent an e-mail to wolfram-u@wolfram.com noting the bad behavior and filed it as a bug in Mathematica.

Here are my rules in taking a Wolfram quiz or cert test. It took me a while to figure these out...

  1. Try as hard as you can on every single question.

  2. Realize that you may still get some questions wrong no matter what you do or know. Don't sweat it.

  3. Appreciate the difficulty in authoring a perfect quiz. There may be bugs, bugs may creep in over time, and you may get some "no win" questions. Flag questions you're pretty sure are buggy in e-mail to Wolfram U. Remember rules 1 and 2, and have fun.

POSTED BY: Phil Earnhardt

Thanks Phil—no kidding on authoring assessments! It's difficult to write questions of the correct difficulty, the right amount of "almost, but not exactly, and wrong in an instructive way" answers, and account for possible bugs, input types, edge cases, and so on. Still, we're always looking to improve and always appreciate any bug reports or suggestions that come our way.

POSTED BY: Arben Kalziqi
Posted 1 year ago

Hi Arben,

I have another question about Manipulate and it ties in with my questions from 3 days ago about 'Stepping back' to previous settings in Manipulate.

One has to be quite careful not to create a loop in a Manipulate construct. E,g. a= a+2 gives already a loop. If done like aNew = a+ 2, then it's ok. More 'funny things' might happen in a more complex Manipulate construction.

My question is : How is the order of the calculations in a Manipulate? Does it go from top to bottom, like line for line (and left to right)? Always? What if I change a parameter (slider) whose appearance is only after 20 lines of code? Is still all the code run from the top, or does the re-calculation start where the changed value first appears (e.g. line 20)?

How can I step through the code and watch the changing variables, like in 'Step-Debug'? Thanks a lot,

Bert

POSTED BY: B. Cornas
Posted 1 year ago

Hi Arben,

I would really appreciate if you could shed some light on these questions of mine. I hope you find the time for it :-)

I read through both "Dynamic & Manipulate Notes" and the "Advanced Dynamic & Manipulate Notes". I could not find anything about the order of execution of the lines of code or step Debug in a Manipulate construct.

Thanks a lot, Beat

POSTED BY: B. Cornas

Hey Bert! I didn't know the answer to this one off the top of my head. After some investigation, I have to say "it's complicated."

From the Advanced Dynamic Functionality Tutorial:

Dynamic expressions can be nested, and the system takes great care to update them only when necessary. Particularly when the contents of a Dynamic contain further interactive elements, it is important to keep track of what will stay static and what will update, when a given variable is changed.

It seems as if for any given dynamic expression, there's a step which involves "tracking down" what pieces of the expression can/will change when certain dynamic variables are updated, and it's those pieces which end up being reevaluated.

POSTED BY: Arben Kalziqi
Posted 1 year ago

Thanks Arben, for your help and work.

It certainly is quite complicated and I started wondering after I found that the code inside Manipulate is not necessarily executed from top to bottom. It is getting even more complicated if there are Dynamic functions explicit withing the Manipulate. Maybe I can come up with some Flags that get set when some line of code is re-executed. I'll have to try.

I will read through the Advanced manipulate and Dynamic paper again :-)

Best, Bert

POSTED BY: B. Cornas

Part of the issue here—and I think why you probably didn't think that the quoted section was useful when you first read it—is that Manipulate is making its own DynamicModule under the hood. This means that even if you're not typing Dynamic[x], the fact that you have (say) {x,1,10} as the second argument to Manipulate means that the constructed DynamicModule does have Dynamic[x] in there—which is why the quoted section is actually relevant, even if you aren't personally typing Dynamic[x].

POSTED BY: Arben Kalziqi
Posted 1 year ago

Very good point, Arben :-)

POSTED BY: B. Cornas

I am having email problems. How do I join the class without today's link? Sorry about this!

POSTED BY: Paul Tikotin

@Paul Tikotin, we'll send your join link to your email, or you can contact us at wolfram-u@wolfram.com to provide a different address, if you're having trouble with gmail. You can also go to the webinar page to register and receive a join link using a different email address. Email communication of some sort will be needed.

POSTED BY: Jamie Peterson

I think I have just sorted the problem,...Thank you!

POSTED BY: Paul Tikotin

I am running Mathematica version 14 under Windows 11 on an HP Envy laptop. To compare AbsoluteTiming for 3 alternative instructions to do the same thing, I wrote the following code and was surprised to see that "Power" was not quite the fastest. (Timing[...] just showed 0. for all 3 instructions.)
I'd appreciate an analysis of my findings.

In[104]:= listOfAssoc=Association@@@({"a"->#[[1]],"b"->#[[2]]}&/@Partition[Range[1000],2]);
tbl=listOfAssoc[[;;2]]

Out[105]= {<|a->1,b->2|>,<|a->3,b->4|>}

In[106]:= First@AbsoluteTiming[Power@@@listOfAssoc]

First@AbsoluteTiming[#a^#b&/@listOfAssoc]

First@AbsoluteTiming[#[[1]]^#[[2]]&/@listOfAssoc]

Out[106]= 0.0118669

Out[107]= 0.0107371

Out[108]= 0.0082883
POSTED BY: Gerald Dorfman

As we're fleshing out project ideas for the level 2 certification, is there someone we can meet with to make sure we're on the right track?

POSTED BY: Kari Grafton

How about a separate Wolfram Community discussion to speculate/brainstorm about L2 cert projects? Anyone can create a new discussion, but it might be good to have the "seal of approval" if @Arben Kalziqi or @Jamie Peterson were to create it. :)

I am looking at a Wolfram Examples project showing muscle co-activation of hand flexors/extensors, arm flexors/extensors, and arm pronators/supinators. The beautiful Anatomy package has the ability to do color illustrations; I can graphically show the muscles involved in particular co-activations. Apparently, the Anatomy package also has identifiers for the antagonist pairs; I need to investigate that. Apologies if those words make no sense; it's better in pictures.

POSTED BY: Phil Earnhardt

I really like this idea! @Arben Kalziqi, @Jamie Peterson, can we make this happen?

POSTED BY: Kari Grafton

While I (hopefully clearly) do enjoy answering everybody's questions here, for something as involved as the Level 2 projects I'm afraid it's not really feasible from a time/involvement perspective. Like Jamie said, please do take advantage of office hours, and we may well offer more things like this in the future. (Actually, typing that reminds me that we have something in the cards for like, an "interesting example + office hour Fridays" series... we'll see if that comes to fruition!)

POSTED BY: Arben Kalziqi

While I (hopefully clearly) do enjoy answering everybody's questions here, for something as involved as the Level 2 projects I'm afraid it's not really feasible from a time/involvement perspective.

Whoa! While I can't speak for @Kari Grafton, my intent was never to turn this proposed discussion group into a place for Wolfram staffers to guide us through any steps of the L2 project process. My intention was to have an informal conversation between participants in the process. In what I'm visualizing, it's probably the case that WR staff participation in the discussion would be counterproductive.

As proposed, the L2 cert process is a solitary interaction between a developer and Wolfram Research. The process is isolated; there's no sense of community in that process. A successful course (like this one) nurtures a sense of community in the participants; that's what I was looking for in a L2 Wolfram Community discussion.

Maybe the discussion group is about encouraging participants to create a project worthy of putting in one of the designated repositories. That project may or may not be sufficient for a L2 certification; that's not really important. I think this is very different from what Arben and Jamie were hearing when they reacted to this discussion.

What is clear: I need to choose words carefully for the first message of the discussion group. Let people know this has nothing to do with anything official that WR is doing. Let them know it's about community. The discussion is more like Stephen Covey's idea in The 8th Habit: Find Your Voice, and Inspire Others to Find Theirs

POSTED BY: Phil Earnhardt

In that case, I support y'all wholeheartedly (imagine I could use emojis here and added a :sweat_smile: at the end there, okay).

POSTED BY: Arben Kalziqi

My best suggestion is to use today's Study Group survey to request your registration at the March 1 instructor office hours, which will also be available as part of the upcoming Programming Proficiency course sequence. Register for the course sequence here.

POSTED BY: Jamie Peterson

Great, thank you! I did request registration for the office hours. And I agree that a L2 discussion board geared towards the participants is a great idea.

POSTED BY: Kari Grafton

Hi Jamie, Cassidy, Abrita, Arben!

Thank you for all your hard work that goes into making these study groups enjoyable. [big smiley]

I enjoyed the fill-in-the-blank format of the Level 1 quiz. Keep that coming. The Level 2 Certificate is on my agenda (the Nutrition Report looks interesting) as are almost every new webinar and WSG. Artisinal Calculus, why, yes, I think I will!

I'm sleeping in today but I will see y'all soon. Stay safe. Stay healthy. Lori

POSTED BY: Lori Johnson

Same! I can't get enough of these webinars and try to do every one that looks like it's even remotely related to something I might use. Or just looks particularly interesting.

POSTED BY: Kari Grafton

Hi Kari!

Nice to meet you! Absolutely. My goal is to learn at least one new piece of creative programming each time, be reminded of a command I may have forgotten, etc. I am seldom disappointed :D

Do you collect session notebooks, too? They're like conference handouts. There are always "goodies" inside.

POSTED BY: Lori Johnson

Thanks Lori! We always enjoy having you with us. Hopefully you enjoy the review recording and notebook if you'd like to peruse them after sleeping in!

POSTED BY: Arben Kalziqi
Posted 1 year ago

Aww, that's a very nice thing to say. Thank you, Arben!!!

Will do! Have a fun weekend :D

POSTED BY: Updating Name

I am trying to rid my code of Do loops as suggested in the training, but I am having some difficulty in getting the simple example in my notebook to work. It is not clear to me how to get the names to cycle through the example. I have several sources of data each with a key value that I am trying to combine into one variable. This is how I am doing it now. I believe if I could figure out how to do the simple example in my attached notebook, I could make the below work.

Do[bE1defgrad[[i]] = 
   Map[Append[#, Select[sEDNH, MemberQ[#, bE1[[i]]] &][[1]][[3]]] &, 
    Map[Append[#, 
       Select[pressure, MemberQ[#, bE1[[i]]] &][[1]][[2]]] &, 
     Select[defGrad, MemberQ[#, bE1[[i]]] &]]];,
 {i, 1, bE1len}]

POSTED BY: Philip Van Riper

Hi Philip,

The code you posted is incomplete, there are several symbols that are not defined sEDNH, pressure, defGrad, ....

I also don't understand what you are trying to accomplish with combined. It just adds an additional level of nesting to dgrad because names includes all of the elements in dgrad

dgrad == First /@ combined
(* True *)

If you just want to pick out the matches to names here is a functional way to do it. There is no need to initialize combined

combined = Select[dgrad, MemberQ[names, First@#] &]
POSTED BY: Rohit Namjoshi

Hey Philip—agree with Rohit here; I'm not sure what you're trying to do exactly. If you could upload a version of the notebook where you've defined everything that you're using and where you've explained what each "step" is supposed to do (like by saying "i have [input], and it does [xyz], resulting in [output]"), I'm sure I'd be able to help.

POSTED BY: Arben Kalziqi

Thanks for the feedback. I am reading several files into my notebook and I ended up simplifying it too much without providing the needed context. Hopefully the attached notebook rectifies this. I basically have three lists that contain data keyed to a list of names. I wish to combine all of the data into one list, but only for the items in the list names.

My background is Fortran, so I instantly think of loops, however the Wolfram language intrigues me and I really want to use it effectively. Phil

POSTED BY: Philip Van Riper

Hi Philip,

I have modified your notebook and added a solution to the end. Light green cells are ones I added.

Attachments:
POSTED BY: Rohit Namjoshi

Rohit, Thanks for the solution. It looks much better that the Do loop and gives me new avenues to explore. Phil

POSTED BY: Philip Van Riper
Posted 1 year ago

package question

All examples of creating a package (after foo::usage=...;bar::usage=...., etc) use

Begin["`Private`"]

and then function bodies follow. Does the word "Private" have some particular significance. What would be the problem with using some other word like

Begin["`NotPrivateAtAll`"]

How is this designation actually used?

POSTED BY: Steven Brawer

Does the word "Private" have some particular significance. What would be the problem with using some other word like [...]

"Private" has no significance. If you go to the Wolfram Language Documentation for Begin, you'll see the examples there use "MyContext`". "Private" is not a keyword in the WL, but [IMHO] the fact that it is a keyword in many programming languages means it should probably be avoided in examples in Wolfram courses. OTOH, "MyContext" is definitely un-keywordy.

It's really helpful to use the Wolfram Language Documentation as the first place to go with questions like this. I don't think that Arben has emphasized the wonderful Wolfram documentation in this course. Docs are available on the web; they are also typically installed in a Mathematica install and can be accessed through a Mathematica window. Carpe documenta!

POSTED BY: Phil Earnhardt
Posted 1 year ago

Thank you. Mathematica documentation could be called "minimal".

Consider the "Begin" documentation. For example, under "applications" there is this for BeginPackage: "Make symbols used for package function definitions private, reducing the possibility for conflict:" Fine. What exactly is the problem with saying: "this defines a namespace" (or at east say Context = namespace)? Unless it doesn't actually define a namespace (or it does, but with lots of caveats), and if not, that should definitely be explained.

Moreover, "Private" is used in the one single "application" section example but not in any examples of the "examples" section. In addition, without a specific statement that "Private" is not special, it is unclear whether using it might have some unanticipated side effect. (In Mathematica, unanticipated side effects are anticipated.) Absence of a comment is not documentation, especially these days when everyone is very busy. If you google "Mathematica packages", there is hardly anything there (or hardly anything simple).

Mathematica is a wonderful and very useful but very complicated system, and the paltry number of examples for such an important subject as Packages means hours wasted trying to figure simple things out.

Here's another interesting thing that is hardly obvious (at least to me, and is probably buried somewhere in a document). Suppose you define G = {x1^n, x2^m} in a program (x1,x2, unassigned symbols) and you want to differentiate G (with respect to x1) in a function someName[G] := ... which is located in a package, where the function body contains D[G[[1]],x1]. As far as I can tell, unless you define the package function as someName[G, x1,x2] and call it from the program as someName[G,x1,x2], it will NOT work. How does the engine know to link the x1,x2 in the call with the x1,x2 in G? This is hardly obvious. There is presumably a whole world of Mathematica-namespace concepts underneath this, which it would be very nice to at least glimpse.

POSTED BY: Steven Brawer

If there are bugs/shortcomings in the documentation, you can file a support ticket with Wolfram.

As far as Private not being a keyword, I just looked up that word in the documentation. Simple. "Private" the String is used as an option in some functions, but that doesn't leak out and affect other things. If a word isn't mentioned in the doc entry for some function, it shouldn't have any magic way to affect that function.

The other thing I noticed with your questions: if you're curious what happens when you do X, just try it. If the kernel behaves in some inexplicable way, that's the point in time to investigate further. I imagine Stephen Wolfram sitting (or standing) in his office in MA; I bet it's in his muscle memory just to try something about before looking it up in the docs or (gasp!) asking another staffer for clarification.

POSTED BY: Phil Earnhardt
Posted 1 year ago

Is there any difference between Proficiency in Wolfram Language Level 1 Certification and Proficiency in Mathematica Level 1 Certification ? It seems that the requirements and the process are the same.

POSTED BY: Artur Piekosz

Good question! While there is significant overlap between the Wolfram Language and Mathematica Level 1 certifications, we are making changes to focus the Wolfram Language certification on programming, and the Mathematica certification on using the product for technical computation. The Level 1 pages and the exam questions will be reflecting these latest changes in upcoming days and weeks.

POSTED BY: Jamie Peterson

Hi there!

I have a question about adding a new variable (Key-> Value) to a list of associations. For instance I recreate the following data

{V1, V2} = {RandomVariate[NormalDistribution[15, 4], 50], 
RandomVariate[NormalDistribution[20, 7], 50]}; (*Create two random variables*)
data = AssociationThread[{"Diameter", "Height"} -> #] & /@  Thread[{V1, V2}];
(*Arrange a list of association*)

Suppose I want to add a new variable, for instance, the logarithm of Diameter variable, however, the only way I succed was using a implicit loop using the table function:

V3 = Log[data[[All, "Diameter"]]];
Table[Append[data[[i, All]], "LogDiameter" -> V3[[i]]], {i, 1, 
Length[V3]}];

I would like to ask if I could add a variable to the association list avoiding the Table function?

Thanks in advance!

Hi Andres,

Here is one way to do it

augmentedData = <|#, "LogDiameter" -> Log[#Diameter]|> & /@ data
Dataset@augmentedData

This relies on the implicit addition of key/value pairs to an Association when wrapped in Association. E.g.

assoc = <|"a" -> 1, "b" -> 2|>
<|assoc, "c" -> 3|>
(* <|"a" -> 1, "b" -> 2, "c" -> 3|> *)
POSTED BY: Rohit Namjoshi

Hi Andres—here are a few implementations that should get your thoughts moving,

If you have access to V1 and V2 directly, you can do:

new = AssociationThread[{"Diameter", "Height", "LogDiameter"} -> #] & /@ 
   Transpose[{V1, V2, V3}];

If you only have direct access to data, you could do this (honestly, I'd do something like this anyway):

new = <|"Diameter" -> #Diameter, "Height" -> #Height, 
     "LogDiameter" -> Log@#Diameter|> & /@ data;

The fastest and shortest way has got to be something like:

new = Append[#, "LogDiameter" -> Log@#Diameter] & /@ data;
POSTED BY: Arben Kalziqi

I just wanted everyone to know that the notebooks for the book "Query" are available at: Query notebooks. I have found them to be a helpful companion to our class.

POSTED BY: Michael O'Connor

When I click on the Grading Rubric link on this page I get

HTTP Error Code 403 Sorry, you do not have permission to access this item.

POSTED BY: Rohit Namjoshi

Hi Rohit, this should be fixed now—works for me, as well. You may need to clear cookies/cache to get it to work, though, as a version with the wrong permissions may be cached on your end.

POSTED BY: Arben Kalziqi

How to create the association command, "<|", vertical bar?

POSTED BY: Taiboo Song

It will depend on your keyboard layout, but a QWERTY layout should have the | accessible by pressing shift and . The < is just a less-than sign, so that's <|association here|>.

POSTED BY: Arben Kalziqi

Arben

The backslash needs to be escaped in the reply window. Shift \

Shift + \

POSTED BY: Rohit Namjoshi

oh god, it escapes even when there's nothing in front of it? blegh, thanks Rohit!

Taiboo: indeed, you want shift + backslash—shift + \

POSTED BY: Arben Kalziqi

Hello Arben: You are an excellent instructor and learning a lot.

When I open your filled-out notebook file, the file shows up as the notebook, with nice colors. But when I open the file class file, it looks different. Why is that and how to get into a nice notebook format for your class notes?

POSTED BY: Taiboo Song

Hey Taiboo—we have two versions of our notebooks, generally speaking. One is the instructor version, which I use when teaching live and which we use for making edits. Then, there's a more monochrome "handout" version which has some formatting changed for consistency's sake and to work nicely on the cloud.

POSTED BY: Arben Kalziqi
Posted 1 year ago

Arben - Two questions:

1.    On the Quiz, is there a way to find out which problem(s) we got wrong?

2.    My "Day01-ListsAndAssociations-Filled.nb" is filled with NULLs. Is there a way to resolve this?

Thanks in advance,

POSTED BY: Updating Name
  1. I don't think so, but if you have a question about a particular question you can ask me. (I also think that if you email us, we can manually pull your answers and which were correct.)
  2. No Nulls for me. You might get them if you don't Enable Dynamics when prompted.
POSTED BY: Arben Kalziqi

The quizzes used to indicate which ones were incorrect, but within the last year that was changed. I found the old method of indicating which answers were correct educational and the new method not so much.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 1 year ago

I have some questions about the Manipulate construction: I have a manipulate with let's say 4 adjustable parameters.

  1. How can I make a button (Previous) to go to the previous values, without getting into an endless loop, which can easily happen in a Manipulate, as if one parameter is changed, everything is recalculated. I tried several ways, like putting the values in a nested list, but somehow there is always something that is not working. Ideally, I want to be able to step back several steps and also forward again (up to the last values I had). I hope my explanation is clear enough :-)

  2. How can I keep the last used values for the 4 parameters when I run the manipulate again? I believe that in a DynamicModule construction, that goes by itself.

  3. How can I easily save the values of the 4 params as a named Preset? Eg.: Preset1. I know that I can do 'Paste snapshot, which gives me all of the original code with the values of the moment, along with the result. This takes a lot of Notebook space, especially when the Manipulate code is substantial. I only want the values of the parameters, so I can load them back in later.

POSTED BY: B. Cornas

Great questions, B—any question I can't immediately answer must be pretty great ;). Let's see...

  1. I think I see what you mean, but some clarification wouldn't hurt. Could you provide a working example of a Manipulate and the behavior you'd like for it to exhibit? The thing about Manipulate is that—unless you specify otherwise via TrackedSymbols, Refresh, and similar—it will simply check for any symbol updates and it will re-compute the result. There's no way that's clear to me to get around this; the thing you're manipulating could depend arbitrarily on these inputs and other things, so it sort of needs to be that way. That said, sometimes you have a Manipulate where there's a "constant" piece which is expensive to compute, and the "dynamic" piece lives on top of it and is generally faster to compute. I don't think that that's what you're talking about, but if so, you can use With and Show to great effect for responsiveness—see attached.

  2. I have a kludgy solution for this and your third question. There's nothing stopping you from defining symbols within a Manipulate, so inside your manipulate you could say something like f[bValue=b,...] and then bValue would be Set to whatever the last value you used on your slider (or other interface element). You can use this as the starting point for the parameter too, so you'd simultaneously save all of your symbols and also be able to keep them as the starting point. Here's an example to get you going:

kValue = 1;
Manipulate[
 Plot[Sin[(kValue = k) x], {x, 0, 2 \[Pi]}], {{k, kValue}, .5, 3}]
Dynamic@kValue
POSTED BY: Arben Kalziqi
Posted 1 year ago

Somehow my post got posted under another name, so here I go again ;

Thanks Arben for your answers and for the truly excellent teaching you do. You bring something extra to the table, sometimes very subtle. Your teachings are top on all levels :-)

For the moment I reply to your answer to my questions 2+3.

I had also come up with creating secondary variables for the adjustable parameters in the Manipulate and assign the these params to the secondary variables. This way They are remembered outside the Manipulate loop. Also handy for debugging.

Building on your example, I came up with the following, which keeps the last used value when I run Manipulate again. (see code at end).

I can also make presets this way and via a Button load them back into Manipulate. I had hoped that there might be an easier way (a Wolfram function) that would do the job, as sometimes I have quite a lot of adjustable parameters in my Manipulates. But it is doable this way.

I'll post a Nb about my first question later.

Manipulate[ kValue = k; Plot[Sin[k x], {x, 0, 2 [Pi]}], {{k, kValue}, .5, 3, Appearance -> "Labeled"}]
POSTED BY: B. Cornas
Posted 1 year ago

Hi Arben, I've come up with an example Nb. It covers some of the 'Previous' and 'Next' possibilities, but not yet all. And it keeps the values last used.

Run the first cell before running the Manipulate, in order to provide initial values for the parameters inside Manipulate.

What it does is : 1. It keeps it's last values when running the Manipulate again, except for the Random pointsXY, which are newly generated each time the Manipulate is run.

  1. It steps back and forward (Button 'Previous' and 'Next'). This only works so far for the position of the lines (pointXY). Click 'Initialize X' and /or 'Initialize Y' buttons a couple of times and you can step back and forward. I limited the stepping back and forward , so no errors can occur (like asking for the a step before the first or beyond the last step).

Now I will try to be able to step back also for the other parameters, but something does not pan out yet.

Attachments:
POSTED BY: B. Cornas
Posted 1 year ago

TOPICS

It would be great if the following topics are covered, OR if there are other courses which cover them (I appreciate that some of these were touched on a bit):

custom packages , non-trivial function bodies, ordinary looping (includingPython-type looping), IDEs which work well, custom types (as in OO programming), name spaces, enums.

At least indicate what Wolfram language calls these structures, and where they are.

For example, list indexing was covered to excess, but there was only just brief touches of defining complicated functions. Custom packages are crucial for organizing any but the simplest programs, and ditto for IDEs. Sometimes speed is not important but flexibility in looping might be needed. Etc.

Thank you

POSTED BY: Steven Brawer

Thanks for the suggestions, Steven—we'll cover some of this in the coming days, and the full course offers a bit more insight than the slightly condensed study group. Once the full course is out later this month, please feel free to attend and tell us directly what you thought, if you'd like!

POSTED BY: Arben Kalziqi

Not in the file provided.

POSTED BY: Taiboo Song

Hi Taiboo, the amoeba folder where all of the materials live should have a data folder now which has all of the data used for today's presentation—as well as tomorrow's.

POSTED BY: Arben Kalziqi

The 2D slider

Manipulate[coordinate, {{coordinate, {0, 0},   "Coordinate"}, {-1, -1}, {1, 1}}] (* 2D slider *)

How would I do a 3D sider?

Manipulate[coordinate, {{coordinate, {0, 0,0},   "Coordinate"}, {-1, -1,-1}, {1, 1,1}}] (* 3D slider *) 

does not work

POSTED BY: Doug Beveridge
Posted 1 year ago

Doug, it would be great to have a 3D Slider. Unfortunately that is not possible on a 2D screen. How would you want to adjust the 3rd (z) axis on a 2D surface? I have been thinking more than 15 years about this and only have come up with complicated solutions, which are not truly 3D.

POSTED BY: B. Cornas

We Create 3D graphics on a 2D surface so we should be able to create a 3D slider .

I have noticed recently how graphics programs use a 3 button mouse to allow 3D movement in a 3D graphic , Is this not a possibility

POSTED BY: Doug Beveridge
Posted 1 year ago

We create 3D images on a 2D surface by means of perspective. To actually control 3 independent axes, you'll need 3 independent 'movements'. Of course, with extra buttons or scroll-wheels, you can add 3 third dimension, but never with a onscreen 3D slider.

What you could do, is assign the z direction to e.g. the y direction when ta button is pressed. But again, this would not be a real 3D slider, more of a work around.

POSTED BY: B. Cornas

Doug, it would be great to have a 3D Slider. Unfortunately that is not possible on a 2D screen. How would you want to adjust the 3rd (z) axis on a 2D surface? I have been thinking more than 15 years about this and only have come up with complicated solutions, which are not truly 3D.

If definitely possible on a 3D surface -- like what the Apple Vision Pro headset provides. That's why Apple is making such a big noise WRT the concept of "spatial computing". Check out the guided tour video published by Apple to get a taste of this. I suspect the hands-on demo -- now available at Apple stores -- would give a much better idea what this is all about. I fondly hope the Wolfram Research brain trust is checking out this tech and prototyping how they can use this tech for brilliant Spatial Computing visualizations.

On the 3D front, there is the work by Joan Horvath and Rich Cameron who have 3D printed objects designed to teach mathematical concepts: Make: Calculus, Make: Geometry, and Make: Trigonometry. AFAIK, nobody has tried to do create physical sliders in their 3DP objects; that's certainly doable. If you're really interested in 3D visualizations, I strongly suggest checking out these books and 3DP the objects that those books use.

POSTED BY: Phil Earnhardt

I also wanted to address Artur's question about @ vs. @* briefly.

It's true that in some contexts they are the same:

f@*g@x === f@g@x === f[g[x]]

but this isn't really the point of Composition/@*. The real use of this (in my experience) is chaining functions together for use in Map or Apply. Consider a basic example:

In[716]:= N@*Mean /@ {{1, 2, 4}, {4, 8, 9}}

Out[716]= {2.33333, 7.}

Here, the @* lets you write a "single composite object" which is the composition of N and Mean. This composition function is then what is mapped across the lists. Simply using @ doesn't do this:

In[715]:= N@Mean /@ {{1, 2, 4}, {4, 8, 9}}

Out[715]= {7/3, 7}

Why? What's happening—visible through Trace, which I'm going to check after I type this side note to confirm my Vibes (they were correct)—is that N@Mean gets evaluated first, and N acting on Mean just provides Mean because there's nothing there to make numeric.

So the idea is:

N@Mean /@ {{1, 2, 4}, {4, 8, 9}} = N[Mean] /@ {{1, 2, 4}, {4, 8, 9}} === Mean /@ {{1, 2, 4}, {4, 8, 9}} === {Mean@{1, 2, 4j}, Mean@{4, 8, 9}} 

whereas

N@*Mean /@ {{1, 2, 4}, {4, 8, 9}} === {N@*Mean@{1, 2, 4j}], N@Mean@{4, 8, 9}} === {N@Mean@{1, 2, 4j}], N@Mean@{4, 8, 9}} 

When composing functions, that's what you want. It can be really useful! Take the example from Good Coding Practices:

Framed@*Highlighted /@ {1, 2, 3} (* Unclear *)

(Framed@*Highlighted) /@ {1, 2, 3} (* Clearer *)

Map[Framed[Highlighted[#]] &, {1, 2, 3}] (* Clearest *)

You could rightfully argue that the first one is unclear, but if you understand how @* works it's very clear and very concise and very easy to write. You're taking the composed operation of "highlighting and then framing" and mapping it across the list {1,2,3}. It doesn't get better than that!

POSTED BY: Arben Kalziqi

The email announcing the recording availability didn't send me to the recording, just to the materials folder (no video there). Also, there was a link to the Quiz, which I'm hesitant to try without watching what went on today. Help?

POSTED BY: David Snyder

The e-mail announcing the availability of the recording of today's session was sent out at ~15:50 Eastern Standard Time today by the "Wolfram U Team". The subject is: "Recording available: Interfaces and Deployment". Search for "Wolfram U Team" in your inbox. The recording is accessed by clicking the "Watch The Recording" button in that e-mail. I called up the video; it is indeed today's recording.

--phil

POSTED BY: Phil Earnhardt
Posted 1 year ago

I did NOT receive this email.

POSTED BY: Steven Brawer

Please contact our staff at wolfram-u@wolfram.com if you need assistance with webinar email notifications from bigmarker.com. This is the mechanism that is used to send Daily Study Group reminders and recording notifications.

POSTED BY: Jamie Peterson

Jamie, it would be cool if Wolfram Research could maintain a list of those BigMarker video archive links for each user in a particular WSG and have them accessible through a Wolfram-U portal in the Wolfram Cloud. All of the user's information for that particular WSG would be stored there. That would provide a reliable mechanism for all users to have the URLs -- and not worry about losing an e-mail through spam filters, force majeure, or whatever. It would also function as a beautiful professional archive for students to reference those training materials in the future. It would be an engaging example for how users can set up small programs establishing highly accessible live data using the Wolfram Language for their own customers.

There's an expense setting this up, but a payout in reducing the day-to-day customer support and customer satisfaction.

I bet there are staffers who could implement this as a one-liner. ;)

POSTED BY: Phil Earnhardt

@Phil Earnhardt, I really like this idea! We have, in fact, had brainstorming sessions about building a Wolfram U portal that would help to archive links to past sessions and courses, certifications, and other useful information. It's good to be reminded there is interest out there. Thanks!

POSTED BY: Jamie Peterson

Well, good. The really interesting thing for me is having a cloud app that Wolfram U users would regularly be using -- and having some sense of what they could [cloud] deploy for themselves.

One of the amazing bits of code that Wolfram U has is the grading engine for the Elementary Introduction to the Wolfram Language course. Anyone who goes through that course without being amazed what the grading engine is doing is just not conscious! Like many, It's tricky: you must have answers that are being produced computationally, but the implementors could not have anticipated everything users could possibly do. I found myself tweaking my answers -- just to see what the engine would judge as "correct" or "incorrect". IMHO, the only shortcoming with the EIWL grading engine is that the source code is not available.

If/when you do this project, please design and implement it with the intention of making the Wolfram Language Notebook source publicly available. Students regularly using it should be curious about its implementation. And people will want to borrow/modify it for their own use; that's what you want. You may even want to do a BigMarker presentation where you walk through the source and explain what/why you do things (both for functionality and for code efficiency).

POSTED BY: Phil Earnhardt
Posted 1 year ago

Trying to understand what Trace is telling me here. I have your words but still do not quite follow. Is it possible to step through this?

Attachment

Attachments:
POSTED BY: Coe Miles

Sure—down the list:

  • The input (with explicit parentheses on the composite function)
  • The Map having been applied takes the composition function and "distributes" it to each term in the nested list, at top level (just f/@{a,b} === {f[a],f[b]})
  • The composite operation/function (N@*Mean) is acting on the first list {1,2,4}, which means that it should be applied like N[Mean[{1,2,4}]]. This is because a composite function f@*g—"the pure operator form of taking g of a thing and then taking f of the result"—acts such that f@*g on a means f[g[a]]. This is the definition of function composition, generally speaking. It's just that in Wolfram Language, we don't write f ∘ g, but f@*g.
  • The expression N[Mean[{1,2,4}]] is evaluated in standard order, from the inside out—first, the Mean is taken, giving 7/3, then N of that result is taken, giving 2.333...
  • The same series of operations is performed on the second list
  • The two results are provided with a List head/wrapper, as that's how Map works (cf. f/@(a+b) === f[a]+f[b] === Plus[f[a],f[b]])

Hopefully that helps, but let me know if not.

POSTED BY: Arben Kalziqi

Folks, it was indeed a trivial yet embarrassing issue—I still had expr defined as a + (b c)/d from last week's lecture :|. You can just do this, and it'll work:

integralAPI = APIFunction[
   {"func" -> "MathExpression"},
   "The integral of " <> ToString[#func] <> " is " <> 
     ToString@Integrate[#func, x] &
   ];

integralAPIDeployed = CloudPublish[
  integralAPI,
  "IntegralAPI"
  ]

As you can see in my deployed version here: https://www.wolframcloud.com/obj/online-courses/PracticalProgramming/IntegralAPI?func=sinx

POSTED BY: Arben Kalziqi

Hi Arben;

Last week you showed an example of Function[] used with a variable as well as a #. Was it your intention to compare a prime function and a non-prime function or a prime function using a # compared to another prime function using a name?

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin

Hey Mitch—"pure" function! But the idea was primarily just to show the "spectrum" from a full, named function with named variables down to a function with no name and whose variables were unnamed. Function of any kind is technically a pure/anonymous function, even if you provide "dummy variable" names for the inputs just like you would in a definition like myNameFunc[x_]:=....

The progression I have in mind is:

mySineAdder[num_]:=num+Sin[num]
Function[num,num+Sin[num]]
Function[#+Sin[#]]
#+Sin[#]&

The first function is a named ("nonymous", you could say, had history taken a different turn). The last three are pure or "anonymous" functions.

POSTED BY: Arben Kalziqi
Posted 1 year ago

Hi Arben and all, I have a question about the last lesson about complexity time on function definition. I have done this notebook and I want to know if there is a simpler complexity way to code the problem.

PLEASE SEE THE NOTEBOOK ATTACHED TO THIS COMMENT

Thanks
Mauro

Attachments:
POSTED BY: Mauro Bertani

Hey Mauro—while I could probably figure this out if I sat and looked at it for a bit of time, I think I need to set the precedent that I can't take arbitrary code and rewrite it for you. However, what I am happy to do is to take an explanation of what your code is actually doing, with some examples, and tell you how I'd write a function that performs the operation in question.

POSTED BY: Arben Kalziqi
Posted 1 year ago

Ok, Arben. I think to have understood where I have made a mistake. It's very fuzzy, how speak with someone change our prospective, by only to expose the problem. Thanks Mauro

POSTED BY: Mauro Bertani

I understand—trying to figure out how to frame and phrase the problem to somebody else is often half the battle!

POSTED BY: Arben Kalziqi

Hey Arben,
In the Friday lecture you did a quick and dirty example of error trapping:

polygonMaker[n_Integer ] := Graphics[{Red, RegularPolygon[n]}]

Then you added a new statement in real time in your Notebook

polygonMaker[___] := "please enter a digit"

I thought basically the three dashes stand for "anything". But it seems in this context they stand for "anything else".
I don't understand the precedence here. How did "else" get implied? I would have thought it redefined the function polygonMaker to always say "please enter a digit" from now on, regardless of the argument. What happened here?

POSTED BY: Carl Hahn