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

[REBOL] Re: nargs

From: cyphre:seznam:cz at: 17-Oct-2003 16:04

Ups, posting in hurry brings always bugs ;) Here is the fixed version: example:
>> nargs 'open
== 1
>> nargs 'open/binary
== 1
>> nargs 'open/binary/mode
== 2
>> nargs 'open/binary/mode/with
== 3
>>
etc. ------------------start of code-------------------- nargs: func [f [word! path!] /local rslt loc? ref? args refs fn rf][ fn: either word? f [ get f ][ rf: copy next to-block f get first f ] args: copy [] refs: copy [] parse third :fn [ any [ set w word! ( either ref? [ insert tail last refs w ][ insert tail args w ] ) | m: refinement! ( ref?: true insert tail refs reduce [m/1 copy []] ) | skip ] to end ] return either rf [ rslt: 0 (length? args) + foreach a rf [ rslt: rslt + length? any reduce [select refs to-refinement a []] ] ][ length? args ] ] ------------------------------end of code----------------------------------