Jump to content

Arguments


The Buzzard

Recommended Posts

Hello to all,

 

Attached below are three formulas to solve for distance for ellipsodial heads of different types.

My question is can each formula be written in one argument or does it need to be written in several?

I am not completely sure how to break this down. Any help on this would be greatly appreciated.

 

Again Thank You in advance,

The Buzzard

IDD2.jpg

Link to comment
Share on other sites

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    10

  • alanjt

    9

  • Lee Mac

    4

  • fixo

    1

Popular Days

Top Posters In This Topic

Posted Images

Sorry,

 

I think I explained myself incorrectly.

What I meant was can each formula be written in one statement with the given arguments.

Link to comment
Share on other sites

Sorry,

 

I think I explained myself incorrectly.

What I meant was can each formula be written in one statement with the given arguments.

Not sure about but have you tried use the COND statement?

 

~'J'~

Link to comment
Share on other sites

I probably overlooked something, but this should be a good example (your first function)...

 

(defun foo (L r O D tt / _sq)
 (setq _sq (lambda (#) (* # #)))

 (- L (sqrt (- (_sq (- L r)) (_sq (/ (* O D) (apply '- (list 2 tt r)))))))
) ;_ defun

Link to comment
Share on other sites

Sorry again,

 

Fixo,

 

I do not mean to combine all three or a way to pick a formula.

For each formula above can the supplied arguments be put into one continuous statement for each formula.

Link to comment
Share on other sites

Thanks Alan,

 

I think I can figure the rest from here.

But what is apply in the statement for.

 

It was to subtract the 3 numbers, but I completely forgot you can add more than 2 numbers to the (- function.

 

(defun foo (L r O D tt / _sq)
 (setq _sq (lambda (#) (* # #)))

 (- L (sqrt (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r))))))
) ;_ defun

Link to comment
Share on other sites

You don't have to use the _sq sub function. However, it saves you a lot of typing and condenses your routine quite a bit.

 

(setq _sq (lambda (#) (* # #)))

Link to comment
Share on other sites

Alan,

 

I looked up apply Function,

 

Passes a list of arguments to, and executes, a specified function.

 

Thanks

Link to comment
Share on other sites

Alan,

 

I looked up apply Function,

 

Passes a list of arguments to, and executes, a specified function.

 

Thanks

 

Hope it helps.:)

And good luck keeping your head on straight while typing everything out. :wacko:

Link to comment
Share on other sites

Nice one Alan :thumbsup:

 

This is the only improvement I can see:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r)))))) nil)

       (  (- L (sqrt n)))))

Link to comment
Share on other sites

Square roots of negative numbers don't exist in the Reals :)

But in that case, could'nt you just use abs in there someplace.

Link to comment
Share on other sites

Nice one Alan :thumbsup:

 

This is the only improvement I can see:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r)))))) nil)

       (  (- L (sqrt n)))))

 

HaHa

I guess we can't have i. Good catch.

Link to comment
Share on other sites

One minor change to #2:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2. tt r)))))) nil)

       (  (- L (sqrt n)))))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...