in reply to Re: Re: Arrays
in thread Comparing Two Arrays

Let's establish some ground rules.

Provide a function that takes two arrayrefs, combines them and returns an array containing all the elements in the previous two arrays, bu no duplicates.

As I don't know them, you can't use commandline opts. *grins*

my @arr1 = (1, 2, 3, 4, 5); my @arr2 = (4, 5, 6, 7, 8); my @arr3 = f(\@arr1, \@arr2); sub f { #234567890#234567890#234567890 @h{map{@$_}@_}=1;keys%h }
23 characters, and I know I can do better.

Update: 22 chars

@h{map@$_,@_}=1;keys%h

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Golf!! (was: Re: Re: Re: Arrays)
by danboo (Beadle) on Dec 08, 2001 at 01:19 UTC
    20 chars:
    sub union { keys%{{map{$_,1}@_}} }
    - danboo

    EDIT: oops, didn't pay attention to instructions. scratch that.