**list directories recursive using a function ( ksh, ksh93)**Hi
I would like to mention that i know "ls" and "find" to traverse a
directory structure recursive.
The goal is to get into each directory and list each directory WITHOUT
using find or ls recursive!
So somehow a find rewritten in shell code.
Example:
Directory structure looks like
../1/2/3/
../1/3/3/
../2/3/1/
../2/3/2/
The result should look like
1
1/2
1/2/3
1/3
1/3/3
2
2/3
2/3/1
2/3/2
Script
cd /tmp
mkdir -p ./1/2/3/ ./1/3/3/ ./2/3/1/ ./2/3/2/
cd -
cat lsr.sh
#!/usr/bin/ksh
f_lsr() {
cd $1
for dir in $( find . ! -name . -ty...

**Re: exporting a list of functions for use in a C function**Hi,
As recommended by others, you should use CForm. I've appended to this
message a function that I use to make minor alterations in the output of
CForm, such as Power -> pow, to yield a more standard form in C++. I hope it
helps.
Tom Burton
On 11/5/03 6:17 AM, in article bob7qo$qu1$1@smc.vnet.net, "Nathan Moore"
<nmoore@physics.umn.edu> wrote:
> I've composed a large list of functions in Mathematica that I'd like to
> have a c function evaluate. To my knowledge c and C++ reject the
> convention x^2 and prefer either x*x or pow(x,2).
...

**Re: How to use Thread when second argument to function is a list of lists?**
small correction:
ref (me)
> This function takes as input the row number and the matrix itself and
> returns a list that contain the non-zero elements in the that row.
>
> i.e. function is f[ list , matrix]:=Module[{},.....]
>
The above should be
f[ rowNumber , matrix]:=Module[{},.....]
i.e. the function f[] takes as argument a number and the matrix. The number
is the row number to process.
Nasser
...

**Re: Define function using lists or tables**Hello. Possibly this is a very simple question.
Is there a way to define a function over a (BIG) list of ordered pairs? I mean, suppose that I have a list, created using a Table command or something like that, of the form [{a,b},{c,d},etc.] such that, after naming it f, say, f = [{a,b},{c,d},etc.], then, afterwards, whenever there is a command such that one needs to compute f[a] (or f[c]), the program immediately replaces f[a] by b,and f[c] by d?
Thank you.
Hi, Joaquim,
One way may be like the following. This is a list to play with:
lst = Partition[Map[ToExpression, Charac...

**Re: Define function using lists or tables #2**Hello. Possibly this is a very simple question.
Is there a way to define a function over a (BIG) list of ordered pairs? I mean, suppose that I have a list, created using a Table command or something like that, of the form [{a,b},{c,d},etc.] such that, after naming it f, say, f = [{a,b},{c,d},etc.], then, afterwards, whenever there is a command such that one needs to compute f[a] (or f[c]), the program immediately replaces f[a] by b,and f[c] by d?
Thank you.
Hi, Joaquim,
One way may be like the following. This is a list to play with:
lst = Partition[Map[ToExpression, Charac...

**Re: [ques]use recursive function to print out n!**�� �ޭz�manoopkammaran@gmail.com (AK)�n���ʨ��G
> Hi
> This is quite easy. You don't need 2 for-loops for that.
> When you get questions like this, keep in mind that all the elements
> need not be put in a single loop.
> Some of them maybe formaing a series while others have to be done
> seperately.
> In your case, the first 10! can be done seperately. The rest forms a
> series, as
> 10!, (10-1)!
> 9!, (9-1)!
> .....
> ......
> .........
> 1!,(1-1)!
> Since you already have a recursive function to computer the factorial
> of a number called fac...

**RE: List arguments to functions**Chris,
If one wants to do parallel operations on the elements of two equal length
lists, and then do something with the resulting outputs, the magic command
is Inner.
For example, to add the elements of the two lists and then leave them in a
list (not what you want)...
Inner[Plus, {1, 2, 3}, {4, 5, 6}, List]
{5, 7, 9}
To get what you want use...
Inner[Plus, {1, 2, 3}, {4, 5, 6}, Plus]
21
If you wanted to take 2 times the element in the first list and add it to
the square of the corresponding element in the second list and then multiply
the results, you could use...
...

**Re: How to use Thread when second argument to function is a list**On 3/10/08 at 2:04 AM, petsie@dordos.net (Peter Pein) wrote:
>Nasser Abbasi schrieb:
>>I have a function which I want to call repeatedly for all rows of a
>>matrix to find non-zero elements in each row. This function takes
>>as input the row number and the matrix itself and returns a list
>>that contain the non-zero elements in the that row.
>this is a task for Map:
>In[1]:= findNonZeroElements[row_, p_] :=
>Select[p[[row]], #1 != 0 & ]
>mchain[p_] :=
>(findNonZeroElements[#1, p] & ) /@ Length[p]]
>p = {{1, 0, 0, 0, 0}...

**Re: How to use list of variables inside Catx function ??**Thank you Nat it worked I forgot "OF" inside the Catx function
SL
On Tue, Sep 1, 2009 at 5:12 PM, Nathaniel Wooding <nathaniel.wooding@dom.com
> wrote:
> Learner:
>
> First, remove the space between col and the colon. It should read col:
>
> Then, an "of" in front of it.
>
> data learner;
> col1='a';
> col2='b';
> col3 = 'c';
> Txdecod = Catx(',',of Col: );
> proc print;run;
>
>
> Nat Wooding
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] ...

**Directory/File recursive listing using standard/portable C?**Just curious: is it possible to recursively list all the
directorys/files inside a given directory using standard c i/o library
routines only, which can be re-compiled and run on any os supportes c
compiler? Or this is too os dependent, system-specific functions must
be called?
I think about this when i tried to do this under windows, i found in
order to achieve this, some windows-specific api such as
FindFirstFile, FindNextFile must be used, so anyway not using them?
Forgive my poor English, Thanks in advance.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
ibic wrote:
> Just curious: is ...

**Re: How to use lookup function to merge data from a standard list**I think that what you mean is that you have two data sets with an equal =
number of rows that you want to merge together, and they match row for =
row, but you don't have an ID field on data 1. =20
Try this:
data data1;
obsnum + 1;
run;
data data2;
obsnum + 1;
run;
data mergeset;
merge data1 data2;
by obsnum;
run;
-Mary
----- Original Message -----=20
From: jn mao=20
To: SAS-L@LISTSERV.UGA.EDU=20
Sent: Wednesday, April 16, 2008 2:27 PM
Subject: How to use lookup function to merge data from a standard list =
file
Hello SAS-Ls,
I have a standard list file...

**Re: How to use list of variables inside Catx function ?? #2**Learner:
First, remove the space between col and the colon. It should read col:
Then, an "of" in front of it.
data learner;
col1='a';
col2='b';
col3 = 'c';
Txdecod = Catx(',',of Col: );
proc print;run;
Nat Wooding
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of SAS_learner
Sent: Tuesday, September 01, 2009 8:05 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to use list of variables inside Catx function ??
Hello all,
I am getting list of Txdecod's after transposing data set, Right now I know
that ...

**Re: How to use lookup function to merge data from a standard list #4**I geez Ill give you the easy version (however id normally do this with a Hash).
Proc SQL ;
Create Table Need As
Select Tbl2.* , Tbl1.Category
From Table2 As Tbl2
Left Join
Table1 As Tbl1
On Tbl1.Var1 = Tbl2.Var2 ;
Quit ;
Toby Dunn
"Don't bail. The best gold is at the bottom of barrels of crap."
Randy Pausch
"Be prepared. Luck is where preparation meets opportunity."
Randy Pausch
> Date: Wed, 16 Apr 2008 12:55:10 -0700
> From: jn_mao@YAHOO.COM
> Subject: Re: How to use lookup function to merge data from a standard...

**Re: How to use lookup function to merge data from a standard list #3**No, the data1 has 100 category and 200 data, var1 has data with fall in 100 category (category). Data2 has 400 subjects. I need to find each subject fall in which category according to var2.
Mary <mlhoward@avalon.net> wrote:
I think that what you mean is that you have two data sets with an equal number of rows that you want to merge together, and they match row for row, but you don't have an ID field on data 1.
Try this:
data data1;
obsnum + 1;
run;
data data2;
obsnum + 1;
run;
data mergeset;
merge data1 data2;
by obsnum;
run;
-M...

**Re: How to use lookup function to merge data from a standard list #7**"Richard A. DeVenezia" <rdevenezia@wildblue.net> wrote: jn mao wrote:
> Hello SAS-Ls,
>
> I have a standard list file with 100 category. And I have another
> data2 file with all subjects. In data2, var2 need be matched to the
> list file, and find the category it belongs.
>
> data1 (list file):
> var1 category
> aa 1
> bb 1
> cc 2
>
> data2:
> Id var2
> 1 aa
> 2 cc
> 3 bb
>
> I need add category to data2. When I tried use merge, I lost all ID
> data which means all ID data become missing. Could someone help me
> to...

**Re: How to use lookup function to merge data from a standard list #6**jn mao wrote:
> Hello SAS-Ls,
>
> I have a standard list file with 100 category. And I have another
> data2 file with all subjects. In data2, var2 need be matched to the
> list file, and find the category it belongs.
>
> data1 (list file):
> var1 category
> aa 1
> bb 1
> cc 2
>
> data2:
> Id var2
> 1 aa
> 2 cc
> 3 bb
>
> I need add category to data2. When I tried use merge, I lost all ID
> data which means all ID data become missing. Could someone help me
> to add the categ...

**Re: How to use lookup function to merge data from a standard list #8**On Wed, 16 Apr 2008 12:27:01 -0700, jn mao <jn_mao@YAHOO.COM> wrote:
>Hello SAS-Ls,
>
> I have a standard list file with 100 category. And I have another data2
file with all subjects. In data2, var2 need be matched to the list file, and
find the category it belongs.
>
> data1 (list file):
> var1 category
> aa 1
> bb 1
> cc 2
>
> data2:
> Id var2
> 1 aa
> 2 cc
> 3 bb
>
> I need add category to data2. When I tried use merge, I lost all ID data
which means all ID data become missing.
I can'...

**Re: How to use lookup function to merge data from a standard list #2**Or just do this:
data mergeset;
merge data1 data2;
run;
And avoid some completely unnecessary I/O.
On Wed, Apr 16, 2008 at 3:39 PM, Mary <mlhoward@avalon.net> wrote:
> I think that what you mean is that you have two data sets with an equal number of rows that you want to merge together, and they match row for row, but you don't have an ID field on data 1.
>
> Try this:
>
> data data1;
> obsnum + 1;
> run;
>
> data data2;
> obsnum + 1;
> run;
>
> data mergeset;
> merge data1 data2;
> by obsnum;
> run;
>
> -Mary
>
&...

**Re: How to use lookup function to merge data from a standard list #5**I see. Let me see if I can guess what your problem is. Data 1 has
100 categories (variables?) and 200 observations. Or, data 1 has a
variable (var1) that has 100 different values and 200 observations.
Data2 has 400 subjects (400 observations?). I think I don't know
enough about var2.
On Wed, Apr 16, 2008 at 3:55 PM, jn mao <jn_mao@yahoo.com> wrote:
> No, the data1 has 100 category and 200 data, var1 has data with fall in 100 category (category). Data2 has 400 subjects. I need to find each subject fall in which category according to var2.
>
>
>
> Mary <mlhoward@a...

**Re: Re: Applying a list of functions to a list of arguments**Hi Jens,
f = {f1, f2, f3};
a = {a1, a2, a3};
Apply @@@ Thread[{f, {#} & /@ a}]
I guess that is supposed to be humorous, but I hope it is never the first
example in a Functional Programming class! It depends a lot on bracket
construction and even when I try to deconstruct it, it certainly doesn't
appear as an obvious path to the solution.
{#} & /@ a
Thread[{f, %}]
Apply @@@ %
But, darn if it doesn't work!
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
From: Jens-Peer Kuska [mailto:kuska@informatik.uni-leipzig.de]
Hi,
Apply @@@...

**RE: Re: Functions inside list** Hi Akil,
> In package.m I do now:
> maxWidthInternal[beta_?NumericQ]:=berekenMaxWidth[beta,linkerO
VCone,cy,dy,centerOfMassx,centerOfMassy,rcAB,ax,ay,rcCD,cx,dx,rcCD,RightVBi,
boundVab,bx,by,partList[[sp]],vdomein];
>
> where all values except beta are known as can be seen in the
> package they are used. berekenMaxWidth is a module defined in
> the same package as maxWidthInternal is called.
> maxWidthInternal is called by anoter Module in the same package.
>
> This solves my problems inside the package they are used, but
> now I get problems...

**Re: Re: pure function to generate a list of**Clear[f]
f[a_, b_, upperLimits_List] :=
NIntegrate[Sqrt[a*x + b], {x, 0, #}] & /@ upperLimits;
f[2, 3, {0.1, 0.5, 0.9}] == {NIntegrate[Sqrt[2 x + 3], {x, 0, 0.1}],
NIntegrate[Sqrt[2 x + 3], {x, 0, 0.5}],
NIntegrate[Sqrt[2 x + 3], {x, 0, 0.9}]}
True
Bob Hanlon
---- Ruth <ruth.lazkoz@ehu.es> wrote:
>
> Thanks to everyone. Bill's was the purest solution of them all (if I
> understand correctly the meaning of purity). However, my example was to=
> naive (linear).
>
> I would like to have a new function with basically the same purity...

**RE: Re: Functions inside list #2** Hi Akil,
<Snippage>
I'm not sure I understand the question ....
It's possible to give your function a set of default arguments that may be
optionally omitted so that ftn[x_, y_:10, z_:30] may be called as
ftn[x], which equates to ftn[x, 20, 30] or ftn[x, 60, 70].
Clearly, this -----------------^^^ is wrong. It should be ftn[x, 10, 30],
and the sentence should finish " or ftn[x, 60, 70] if you choose to override
the default arguments (with eg. 60 & 70)".
Stil don't understand the question though ....
D.
...

**exporting a list of functions for use in a C function**I've composed a large list of functions in Mathematica that I'd like to
have a c function evaluate. To my knowledge c and C++ reject the
convention x^2 and prefer either x*x or pow(x,2). The functions are
integer powers of a single variable. I'm using the command,
Export["function_list.txt", Table[gflist[p], {p, 2, 5}], "CSV"]
where "gflist[n]" generates the said set of functions for the case "n".
The output file then looks like:
[winesap:~] nmoore% cat function_list.txt
1/(8*d*l^3*Pi)
1/(8*l^3*Pi),-(-3 + d)/(16*d*l^3*...