Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: programming comptition II (correction)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg5051] Re: [mg5043] programming comptition II (correction)
  • From: fransm at win.tue.nl (Frans Martens)
  • Date: Wed, 23 Oct 1996 01:38:12 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

My previous solution of Problem One was wrong.
The wrong solution is with the example:

li1 = Array[f, {2,3,4}]
li2 = Array[g, {2,3,4}]

  Times[li1,li2]

A solution is

MapThread[List,{li1,li2},Length[Dimensions[li1]]]

Frans Martens
Eindhoven University of Technology
The Netherlands

Begin forwarded message:

>From: Xah Lee <xah at best.com>
>Subject: [mg5043] programming comptition II

Two pure programing problems some of you will enjoy.

Problem One: Constructing Dimensions.
Given a one dimensional list, how to partition it so it becomes a  
nested
list with a specified Dimensions. Example and solution:

Array[f, {5,2,3}]
First@ Fold[Partition, Flatten@ %, Reverse at {5,2,3} ]
%% === %

--------------------------------------

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}
]

--------------------------------------
Please post your alternative approach.

 Xah
 xah at best.com; 74631.731 at compuserve.com
 http://www.best.com/~xah/SpecialPlaneCurves_dir/specialPlaneCurves.ht 
ml
 Mountain View, CA, USA




  • Prev by Date: Re: programming comptition II
  • Next by Date: New Maeder book
  • Previous by thread: Re: programming comptition II
  • Next by thread: New Maeder book