Yeah, we'relookingattreeslikethose, actually, treesandcomputerscience a littlebitdifferent.
Youknow, thewoodisontopandtheleavesonbottom.
That's a rottenthingtorememberaboutthree.
Somanypeopledon't know.
I wanttotalkabouttrees.
Andi, I wanttoshowhowTowwhatever, Christreesinusingpythonandusingobjects.
No, Uh, pleasearevery, veryversatiledatastructure, and I thinkthey'reoftenbutunderuse.
Somepeoplealwayswanttoyourstringsforeverything.
And I think a goodprogram a reallyneedstheirtrees, youknow?
Sotheexamplewe'regoingtolook a TTE a syntaxtrees, And, uhsoletmejuststartusAnexample S Sowe'relookingat a mathematicalexpression, somethinglikewetimesbyplus X.
That's a mathematicalexpression.
Andthere's another 13 times.
Whyplus X.
Nowpeoplemaythinkit's it's It's like a sequencelike a stringondhe.
Actually, I thinkthisgoessomemore, general.
I mean, andyouandyoulearnmathematics.
Myimpressionisthatlotsofpeoplegetconfusedbythinkingoffarithmeticexpressionitselflike a onedimensionalstructurefromlefttoright.
Youcanavoidhavingtoputbracketsherebecause, asyouknow, thereisonly a a limitednumberofblackitintheworldandtobetriedtosafebreakers.
There's really a blackitsavingdevice.
Butreally, ifyoulookatthetrees, thebracketscompletelydisappearandwereallyseeis a structurethatyoumeanifheevaluatesthem, ifheassignedvaluestovieandtwo X andthenweveryit's somethingwegetdifferentanswersforthesetwoexpressionsforthosetwotrees.
Buttobehonest, whenyoustartwriting a programandyouwrite a prototype, oftenyouendupcopyingsomecoatandthenlateryouhaveanotherlookatyouratyourcourtinnewstarttodefectortoeeffectoutthescopies.
Evenso, I getthetimesobjectandittellsmethatitlivesatthisaddresswhichisveryexcitingandalwayswantedtoknowwheremytime's objectlivesincase I wanttovisititlikebutthat's notenough.
Wewantedtoseewhatwehaveisunderthesetreesandokay, maybewewouldn't go a CEfarceexpectingittodraw a tree.
So I mean, it's offlikeaninternalmethodforPiperandwewenttodefineanothermessageisdoubleunderlinesinthismethodisthestrmethodandletmeknowStartwiththewiththeoperatorsthatthe 1st 2 howtoput a valuablesothat's particularlyeasy.
Sodeafsoonstrmissit.
It's supposedtoreturnpresentationofftheobjectasthestringandthisisparticularlyeasyinthecaseof a variablebecauseofeveryrepresentedthisthing.
Sowejustreturnthename.
Okay, sonowwecanprintvalueless.
ButwhataboutConstance?
CanreprintConstance.
Okay, Soconstantescapism.
There's a numberandprivatealreadyknowshowtoturnnumbersintostringbyjustusingstrsointerestingTurn, Stuhuh?
OffselfdotWhat?
Butnowlet's gotothemoreinterestingcases.
Howdoweplant a timesthreenowwhatwewanttoprintWewanttoputtheleft, expressionthetimesandthendivideexpressionandlet's ignorethebracketthinginthemomentwhenwegetbacktothisandit's justoozesSodeath.
Strselfand I wanttoreturnsomething.
Namely I turnmyleftexplosion.
ThisisSefton L into a stringandhereusingstrButthishigh, it's thatwhat's reallygoingon?
It's a recordinbecausestrtriestoplantthisexpressionsoit's goingtocalltheunderlineunderlinestrmethodforthisobject, whicheverjustdefininghere.
Andinthecaseoftheconstant, actuallytheenvironmentiscompletelyignoredbecauseallyouhavetodoistoreturntheveryyoubecausetheveryoff a constantdoesn't actuallydependontheassignment.
Twovery.
It's nonext.
That's theveryimagewhichis a bitmoreinterestingbecausetherewedogetthedependency.
AndherewereallyseetherecordsinbecausetoevaluatetimesvaryitTheleftexpression I amveryIt's a lightexpressionandthenmultiplyresults.
Okay, so I seesaidif I gotherthatEvathatusedthesameenvironmenttimessafedotahdotEvolvedthesameenvironmentsneakyRikersinwastheoneforstrbecausehecouldn't seeittowards.
Sobecausehere, sounderstrcallsstrbutactuallystrcalledunderlinestrSotherewas a sneakybecausethisoneisactuallynotsneakybecausewedefineevil, andthenwecallevil.
Soit's reallyincursionwith, becauseit's a commonsituation.
Ifyouhave a distractionlike a treeandyouwanttoprocessityouBecauseif I recall, you'resafeonthesubstructure.
So I don't reallyknowwhattheancestorshavetocalculateit.
What's theanswer?
Okay, threetimestwoplusfouris 18.
Let's see, right?
Yep.
Bythenandnow, thesecondexpressionCorviswascalledtoyou R f threetimesfor 12 plus 2 14 threetimesforest, Plustohis 14 yearangryyetandpersonallyknowatthispoint, youcouldsayOkay, fine.