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

[REBOL] Re: Suggestion for Rebol-list

From: joel:neely:fedex at: 14-Mar-2002 19:57

Hi, Norman, [rebolinth--nodep--dds--nl] wrote:
> to-positive: func ["Converts to positive value." value "Value to convert"] > [to integer! :value ] [ value: value - (value + value) ] > > to-negative: func ["Converts to positive value." value "Value to convert"] > [to integer! :value] [ value: - value ] >
The existing REBOL word ABS returns the non-negative (don't forget about zero! ;-) magnitude of its argument, as in
>> abs 5
== 5
>> abs -5
== 5 AFAICT, that's what TO-POSITIVE was expected to do. Romano has already mentioned NEGATE, which seems to cover the goal of TO-NEGATIVE. Finally, on notation and style, you could drop the value: from both of your proposed functions, simply allowing the value of the remaining expression to be returned. -jn- -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;