MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: programming comptition II


In article <54f397$74f at dragonfly.wolfram.com>, Xah Lee  <xah at best.com> wrote:
>Problem Two: Pairing of Nodes.
>Given two list of the same Dimensions, how to combine the list so that
>the end nodes of the new list pair the end nodes of given lists. Example
>and solution:
>
>Clear[li1, li2]
>
>li1 = Array[f, {2,3,4}]
>li2 = Array[g, {2,3,4}]
>
>Transpose[ {li1, li2},
>RotateRight@ Range@ Length@ Dimensions@ {li1, li2}
>]

Mathematica has built-in functions for dealing with multiple lists.
   MapThread[List, {li1, li2}, Depth[li1] -2]
Alternately, you can get around the fact that List[] isn't listable with
   ListableFunction[li1, li2] /. ListableFunction -> List
For example
   li1 + li2 /. Plus -> List
This won't work with numbers; the function will be evaluated at
the number pairs and each pair will be replaced by a single value.

-- 
Bob Hall            | "Know thyself? Absurd direction!
rhall2 at gl.umbc.edu  |  Bubbles bear no introspection."  -Khushhal Khan Khatak


  • Prev by Date: error message
  • Next by Date: Re: Why no solution to 3 eqns. in 3 unk. ?
  • Previous by thread: Re: programming comptition II
  • Next by thread: Re: programming comptition II (correction)