[Cs254f11] Wow. Basic question

Wm. Josiah Erikson wjerikson at hampshire.edu
Wed Oct 26 10:01:55 EDT 2011


Ha! See, I knew it would be that simple. I didn't realize that "vector" 
was a function. But of course it is :)
Now another question - there must be a neat function that takes a 
collection and returns a collection of the unique values, yes? Like if I had

( a b c d a b e d g h d r q)

it would return

(a b c d e g h r q)

Oh wait, just found it. It's called "distinct". I knew it would exist :)

Excellent. Now my "count the frequencies of all the notes in the song" 
function should run much faster.

Thanks,
    -Josiah


Lee Spector wrote:
> (def a '(1 2 3 4 5))
>
> (def b '(i j l k m))
>
> (map vector a b)
>
> ; ([1 i] [2 j] [3 l] [4 k] [5 m])
>
> That what you wanted?
>
>  -Lee
>
>
> On Oct 25, 2011, at 11:00 PM, Wm. Josiah Erikson wrote:
>
>   
>> I must be up too late.
>>
>> I have a list, a, and another list, b.
>>
>> I want to make a new list of two-item vectors that is both lists put together, so that it will look like ([(nth a 1)(nth b 1)][(nth a 2)(nth b 2)][(nth a 3)(nth b 3)])
>>
>> ...and so on. interleave doesn't quite do what I want. Maybe in the morning it will occur to me how to do this without a loop. If it's obvious to somebody else, will you help me out?
>>
>> Thanks in advance,
>>
>> -- 
>> -----
>> Wm. Josiah Erikson
>> Network Engineer
>> Hampshire College
>> Amherst, MA 01002
>>
>> _______________________________________________
>> Cs254f11 mailing list
>> Cs254f11 at lists.hampshire.edu
>> https://lists.hampshire.edu/mailman/listinfo/cs254f11
>>     
>
> --
> Lee Spector, Professor of Computer Science
> Cognitive Science, Hampshire College
> 893 West Street, Amherst, MA 01002-3359
> lspector at hampshire.edu, http://hampshire.edu/lspector/
> Phone: 413-559-5352, Fax: 413-559-5438
>
>   

-- 
-----
Wm. Josiah Erikson
Network Engineer
Hampshire College
Amherst, MA 01002



More information about the Cs254f11 mailing list