But then this (the example below) explicitly lists the refinements in the
function body. I think the "ultimate" solution would process an arbitray
list, as with a loop. It is fairly short though :) and IS a step up from
'if statements, esp for more than 2 refinements.

- Michael Jelinek





[EMAIL PROTECTED] on 09/15/2000 04:04:34 PM

From: [EMAIL PROTECTED] on 09/15/2000 04:04 PM

Please respond to [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
cc:
Subject:  [REBOL] best means of passing refinements from main to helper
      function? Re:(2)




       Howdy, Michael:

  The following approach is exactly elegant, but it gets the
  job done and it's fairly short.  I think it's kind of cute.

  -jeff

REBOL []

deduction: func [
    /use-month month-to-use
    /use-day day-to-use
][
    rejoin [ "file-"
         either use-month [ month-to-use ] [ now/month ]
         either use-day   [ day-to-use ]   [ now/day  ]
    ]
]

main: func [
    /use-month month-to-use
    /use-day day-to-use
] [
    go?: func ['what /it][either it: get what [either true = it [what][it]]
[]]
    do reduce compose/deep [to-path [deduction (go? use-month) (go?
use-day)]
                    (go? month-to-use) (go? day-to-use)]
]


> This seems   to be  an  occasionally reoccurring  topic. In
> short  I don't   think anyone  has come  up   with a simple
> elegant way of  doing this. A few  of us have come up  with
> solutions  which    involve  building  the  helper-function
> call/refinements string. You might  find, however, that you
> would rather use a bunch of 'if statements.
>
> - Michael Jelinek
>
>
>
>
>
> [EMAIL PROTECTED]@MailAndNews.com>  on  09/15/2000
> 03:30:03 PM
>
> From:    [EMAIL PROTECTED]@MailAndNews.com      on
> 09/15/2000 03:30 PM
>
> Please respond to [EMAIL PROTECTED]
>
> Sent by: Terrence Brannon <[EMAIL PROTECTED]>
>
> To: [EMAIL PROTECTED]  cc:   Subject: [REBOL]  best  means  of
> passing refinements from main to helper
>        function?
>
>
> I  want  to know the     best way to  propagate  refinement
> selections (or  their lack)  to  a function  which actually
> does the processing for them.









Reply via email to