in reply to Saving array duplicates, not using a hash?

Is that even possible?
Absolutely, that chapter should have taught you how. Here's some pseudo code
for each ELEMENT of ARRAY if ELEMENT found in OTHERARRAY then print ELEMENT else add ELEMENT to OTHERARRAY calculate raise ... endif endfor ...
guess what, the part that checks for duplicates without hashes looks exactly like this first :)

Replies are listed 'Best First'.
Re^2: Saving array duplicates, not using a hash?
by gctaylor1 (Hermit) on Sep 28, 2008 at 07:38 UTC
    1. I don't understand what I would use for OTHERARRAY?
    2. The if compares to a single element in OTHERARRAY right? How would I get at the single element unless I use another for loop to cycle through it?
      1. I don't understand what I would use for OTHERARRAY?
      Something like @OTHERARRAY or @SOMETHING, @POOPS, @MCGEE, @FOO, @BAR, @BAZ, @MOO, @SHOO, @GCTAYLOR1, @ELEMENTSSEENALREADY... :) understand? ARRAY is one name, OTHERARRAY is another.

      2. The if compares to a single element in OTHERARRAY right? How would I get at the single element unless I use another for loop to cycle through it?
      Almost, it compares to every single element in OTHERARRAY, and you use another loop for that. Loops are the basis for computers (everything is a loop, from RAM to CPU). Its one of those fundamental you must master, so stick to it and it will stick to you :)
      foreach String comparison

      After you've got that loop version working, next step is to do it without an explicit loop. You'll be using index and join :)