Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Summing a list

From: izkata:gm:ail at: 2-Sep-2010 11:23

'if doesn't have an else-block by default. You can use "help if" to see its refinements. Two ways to do it, one with the refinement, the other with a different function: if/else empty? series [0] [add first series suma next series] either empty? series [0] [add first series suma next series] What Sunanda is doing is, exiting the function early if the series is empty. That way the remainder only gets evaluated if the series is not empty, acting like an 'else' without actually being one. On Thu, Sep 2, 2010 at 11:06 AM, Emeka <emekamicro-gmail.com> wrote:
> Sunanda, > > I thought that "if" signature is this: > > if good-enough? nums [ bla blal] [weep weep] > > Why is it that yours is different? > Emeka > > On Thu, Sep 2, 2010 at 4:57 PM, Sunanda <dhsunanda-gmail.com> wrote: > > > > > Try this: > > > > suma: func [series] [ > > if empty? series [return 0] > > add first series suma next series > > ] > > > > > > Your problem was having the [add first...] in a block. It needs to be > > open code > > > > Sunanda > > -- > > To unsubscribe from the list, just send an email to > > lists at rebol.com with unsubscribe as the subject. > > > > > > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- <*>