abbreviation of arguments in function

Q&A's, tips, howto's

abbreviation of arguments in function

Postby lyl » Sun Dec 09, 2018 8:44 am

To understand the meaning of function arguments, I give there arguments long names. However, it's so boring to use these long names in function body.
I ttied like this:

Code: Select all
(define (f converse-rate-list (define rate converse-rate) )
   body in which "rate" instead of converse-rate-list is use....)


But it fails.
Is there a better way to achievable this goal? That is to say, how to bind a symbol to a argument of function?
lyl
 
Posts: 10
Joined: Sun Mar 25, 2018 5:00 am

Re: abbreviation of arguments in function

Postby cameyo » Sun Dec 09, 2018 3:33 pm

Code: Select all
(define (f converse-rate-list)
  (local (rate) (setq rate converse-rate-list))
)

I am almost sure that this is not what you are searching for... :-)
cameyo
cameyo
 
Posts: 31
Joined: Sun Mar 27, 2011 3:07 pm

Re: abbreviation of arguments in function

Postby rickyboy » Sun Dec 09, 2018 6:19 pm

This is the perfect case for a doc string or a comment.

Code: Select all
(define (f rate)
  “Given converse rate list `rate`, does ...”
  ... code using rate ...)
(λx. x x) (λx. x x)
rickyboy
 
Posts: 557
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: abbreviation of arguments in function

Postby lyl » Mon Dec 10, 2018 1:08 pm

@rickyboy What? Newlisp has a elisp style? It's a supprise!
lyl
 
Posts: 10
Joined: Sun Mar 25, 2018 5:00 am

Re: abbreviation of arguments in function

Postby lyl » Mon Dec 10, 2018 1:11 pm

cameyo wrote:
Code: Select all
(define (f converse-rate-list)
  (local (rate) (setq rate converse-rate-list))
)

I am almost sure that this is not what you are searching for... :-)
cameyo


I'd like to have a try this. Thank you.
lyl
 
Posts: 10
Joined: Sun Mar 25, 2018 5:00 am


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron