Mercurial > hg > ishara
diff general/funutils/maprows.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/general/funutils/maprows.m Sat Jan 12 19:21:22 2013 +0000 @@ -0,0 +1,16 @@ +function Y=maprows(f,X) +% maprows - Map a function of a vector over the rows of an array +% +% maprows :: +% ([[1,N]->A] -> [[1,M]->B]) ~'function maps a row of A to a row of B', +% [[L,N]->A] +% -> [[L,M]->B]. + +n=size(X,1); +if n==0, Y=[]; +else + for i=n:-1:1 + Y(i,:)=f(X(i,:)); + end +end +