help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'map' function in Octave-Forge


From: Tomer Altman
Subject: 'map' function in Octave-Forge
Date: Sun, 23 Nov 2003 14:30:01 -0800 (PST)

Introducing 'map':

  ## usage: [ result ] = map ( FUN_STR, ARG1, ... )
  ##
  ## map, like LISP's ( & numerous other language's ) function for
  ## iterating the result of a function applied to each of the data
  ## structure's elements in turn. The results are stored in the
  ## corresponding input's place. For now, just will work with cells
  ##and
  ## matrices, but support for structs are intended for future
  ##versions.
  ## Also, only "prefix" functions ( like "min(a,b,c,..)" ) are
  ## supported.
  ##
  ## Example:
  ##
  ## octave> A
  ## A 
  ## {
  ##   [1,1] = 0.0096243
  ##   [2,1] = 0.82781
  ##   [1,2] = 0.052571
  ##   [2,2] = 0.84645
  ## }
  ## octave> B
  ## B =
  ## {
  ##   [1,1] = 0.75563
  ##   [2,1] = 0.84858
  ##   [1,2] = 0.16765
  ##   [2,2] = 0.85477
  ## }
  ## octave> map("min",A,B)
  ## ans =
  ## {
  ##   [1,1] = 0.0096243
  ##   [2,1] = 0.82781
  ##   [1,2] = 0.052571
  ##   [2,2] = 0.84645
  ## }

Uploaded to Octave-Forge:

octave-forge/main/miscellaneous

---

Cheers,

~Tomer

Attachment: map.m
Description: Map M-file


reply via email to

[Prev in Thread] Current Thread [Next in Thread]