Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 1.5

COLUMN

Memoizing

How to Take Good Notes

Issue: 1.5 (April/May 2003)
Author: Matt Neuburg
Author Bio: Matt Neuburg is the author of REALbasic: The Definitive Guide, and a member of the editorial board of REALbasic Developer.
Article Description: No description available.
Article Length (in bytes): 14,238
Starting Page Number: 34
Article Number: 1517
Resource File(s):

Download Icon 1517.zip Updated: 2013-03-11 19:07:56

Related Link(s): None

Excerpt of article text...

The term "memoizing" is not a misspelling of "memorizing," but the two notions are related. Memoizing is a technique that can come in handy in programming situations where you're performing a calculation that has input, and the same input always yields the same result. The motivation for memoizing arises when the calculation is lengthy and is likely to be performed on the same input more than once. Memoizing itself is a cross between simply performing the calculation, on the one hand, and looking up the answer in a table, on the other.

Perhaps before going any further I should pause to point out that a lookup table is itself an important programming technique that is often neglected by beginners -- perhaps because it seems too easy, or too obvious. For example, suppose you had to implement REALbasic's Hex function, which translates a decimal integer to a hex string. What this really boils down to is translating a value between 0 and 15 into a hex digit, so let's concentrate on that. Clearly there are two cases. If the value is between 0 and 9, we can use it as an offset from the ascii value of the character "0". If it's between 10 and 15, we can subtract 10 and use the result as an offset from the ascii value of the character "A".

Hexify By Calculation

Function hexify(i as integer) As string

dim base as integer

...End of Excerpt. Please purchase the magazine to read the full article.