gmazel

//Am I missing a reference in LinqPad? //I get an error in LinqPad on line 9 below from Listing 2-14. Generate Logo commands to draw a //Serpinski triangle.linq: //"CS0103 The name 'serpinskyTriangle' does not exist in the current context" * string serpinskiTriangle = "A"; * Func transformA = x => x.Replace("A","B-A-B"); * Func markBs = x => x.Replace("B","[B]"); * Func transformB = x => x.Replace("[B]","A+B+A"); * int length = 6; * Enumerable.Range(1,length) * .ToList() * .ForEach (k => serpinskiTriangle = * transformB(transformA(markBs(serpinskyTriangle)))); * * serpinskiTriangle * .Replace("A", "forward 5" + Environment.NewLine) * .Replace("B", "forward 5" + Environment.NewLine) * .Replace("+", "left 60" + Environment.NewLine) * .Replace("-", "right 60" + Environment.NewLine) * .Dump("LOGO Commands for drawing Serpinsky Triangle"); // Thanks! // Gregg

About

Username
gmazel
Joined
Visits
11
Last Active
Roles
Member
Points
20

Activity

  • Not much happening here, yet.
Avatar

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!