Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: How can I parse arguments of an expression unevaluated?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100941] Re: How can I parse arguments of an expression unevaluated?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 18 Jun 2009 06:26:31 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <h1cv17$j6v$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

SetAttributes[MyFunArgs, HoldAll]

MyFunArgs[1, 2, a = 3, b = 4] /. Verbatim[Set][a_, b_] :> {a, b} /.
   MyFunArgs[a : Except[_?AtomQ] ..., b__?AtomQ,
     c : Except[_?AtomQ] ...] :> MyFunArgs[a, {b}, c] /.
  MyFunArgs[a__, lst : {_Symbol, _} ..] :>
   MyFunArgs @@ {a, Sequence @@ Transpose[{lst}]}

?

Regards
   Jens

Erich Neuwirth wrote:
> What I would like to have is the following:
> I want to give the expression
> MyFunArgs[1, 2, a = 3, b = 4]
> and I would like to get 3 lists,
> the first list has all the arguments which are
> not written as an assignment, {1,2}
> The second list should be a list of strings
> with the names of the variables to be assignes
> {"a","b"}
> and the third list should be the values to be assigned:
> {3,4}
> 
> so
> MyFunArgs[1, 2, a = 3, b = 4]
> should produce
> {{1,2},{"a","b"},{3,4}}
> 
> How can I accomplish this?
> 
> 


  • Prev by Date: Re: Hilbert transform bug in 7.0.3?
  • Next by Date: Huge wide plot placing into a pane
  • Previous by thread: Re: How can I parse arguments of an expression unevaluated?
  • Next by thread: Re: How can I parse arguments of an expression unevaluated?