{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Using Templates

Using Templates - CS1102 Using Templates Effectively Using...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1102 : Using Templates Effectively Using Templates Effectively Many of you headed down complicated paths when asked to implement sort following the template. Most of you ran into one of two (related) problems: You started thinking about algorithms too early You weren't sure how to use the template Templates defer questions about the logic/algorithm of a program until after its core structure is in place. If you know how to use the template, you get a lot of code written down that can then help you think out an algorithm. The design process becomes a lot more manageable. Step 1: Write the Template Writing the template means writing the whole template, not just the cond (because as soon as you had that much you started thinking about the algorithm). The whole template for sort looked like ;; sort : list-of-number -> list-of-number[sorted] ;; sort list of numbers into increasing order (define (sort alon) (cond [(empty? alon) ...] [(cons? alon) ... (first alon) ... (sort (rest alon))]))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}