The Buzzard Posted June 5, 2009 Share Posted June 5, 2009 Hello to All, Sorry, for the blank post will have this removed. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 5, 2009 Share Posted June 5, 2009 ... V = Ir Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 5, 2009 Author Share Posted June 5, 2009 Sorry Lee, I have all of the formulas figured out and now written. I wanted to get this thread deleted. I am waiting for a moderator to do it. Thanks Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 5, 2009 Share Posted June 5, 2009 Something my physics professor in college drilled into our heads... Twinkle twinkle little star, power equals i-squared r Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 6, 2009 Share Posted June 6, 2009 Haha, nice - my teacher used to say: Power = Ivy Watts... I never found out who Ivy Watts was though.. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 6, 2009 Author Share Posted June 6, 2009 Here they are: P = VxI OR (setq P (* V I)) P = RxI² OR (setq P (* (* I I) R)) V² P = – OR (setq P (/ (* V V) R)) R V = RxI OR (setq V (* R I)) P V = – OR (setq V (/ P I)) I ___ V = √PxR OR (setq V (sqrt (* P R))) V R = – OR (setq R (/ V I)) I V² R = – OR (setq R (/ (* V V) P)) P P R = – OR (setq R (/ P (* I I))) I² V I = – OR (setq I (/ V R)) R P I = – OR (setq I (/ P V)) V _ √P I = - OR (setq I (sqrt (/ P R))) R Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 6, 2009 Share Posted June 6, 2009 Interestingly enough, I was browsing my C book earlier today and I saw something called polymorphism. I never knew that computer code could be so inherently flexible. Is that a property of the code, or the compiler? Seeing all those equations, it reminded me, and made me wonder.. would it be possible to write a polymorphic function in LISP, or does LISP not have that ability? Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 6, 2009 Author Share Posted June 6, 2009 Freerefill. Are you referring to this: eg V = √PxR I was just using the windows character map to show which formula belongs to which lisp calculation. Its just for reference. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 6, 2009 Author Share Posted June 6, 2009 Here are just the lisp calcs for less confusion. (setq P (* V I)) (setq P (* (* I I) R)) (setq P (/ (* V V) R)) (setq V (* R I)) (setq V (/ P I)) (setq V (sqrt (* P R))) (setq R (/ V I)) (setq R (/ (* V V) P)) (setq R (/ P (* I I))) (setq I (/ V R)) (setq I (/ P V)) (setq I (sqrt (/ P R))) Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 6, 2009 Share Posted June 6, 2009 Polymorphism (as I was able to understand it) basically means you have a single function call that accepts different types of information but spits out the same result. In this case, all those functions are basically the same algebraically. Suppose you wanted to write a single function where you could input any two and be sure to have the third returned. My C book gives an example.. I'll translate it into LISP so you can see what the theory is. Obviously, this won't work, but a similar setup in C++ apparently will. ; Create two functions (defun square(pt1 pt2 pt3 pt4 / ) (command "pline" pt1 pt2 pt3 pt4 pt1 "") ) (defun square(pt1 length width / ) (command "rectang" pt1 (list (+ (car pt1) width) (+ (cadr pt1) height) (caddr pt1))) ) ; Create a square two different ways, but call the same function (square '(0 0 0) '(0 1 0) '(1 1 0) '(1 0 0)) (square '(0 0 0) 1 1) If this was rendered in C++ and compiled, it would work. The compiled program would automatically know which version of (square) to use depending on the input. The only way I could think to translate this into LISP is to manually put in checks for data, which is entirely doable I'm sure, but that doesn't stop me from wondering if there are creative alternatives. And yes, this does boil down to another completely useless speculation of mine. But hey, if it makes you guys think, mission accomplished~ Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 6, 2009 Author Share Posted June 6, 2009 That is basically what I plan to do. I am using this for an Ohms Law Calculator. You would pick the operation you want to perform and supply the two knowns and have the third returned. I am going to do this with a DCL and vector image to confirm the proper calcs to the user. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 6, 2009 Author Share Posted June 6, 2009 Obviously I am not using these calcs as you see displayed. They will be arranged in their respected functions. Earlier I got hung up with two of the calcs and was looking for help, But I decided to figure it out for myself. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 6, 2009 Share Posted June 6, 2009 Here is an interesting resource for that kind of stuff. http://www.engineeringtoolbox.com/ If I remember correctly ( from way back ) Ohm's law is used for single phase power, 3 phase stuff has differing values. -David Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted June 6, 2009 Share Posted June 6, 2009 In C#, I think it is called overloading the constructor. Basically what you described is correct, you write a bunch of functions with the same name, and depending on what you put in, it spits out the correct 3rd piece as the answer. Quote Link to comment Share on other sites More sharing options...
CAB Posted June 7, 2009 Share Posted June 7, 2009 I should test these lisp but too lazy. ;; supply two of the three arguments to get the third (defun OhmsLawPVR (P V R) (cond ((not P) (/ (* V V) R)) ((not V) (sqrt (* P R))) ((not R) (/ (* V V) P)) ) ) (defun OhmsLawPVI (P V I) (cond ((not P) (* V I)) ((not V) (/ P I)) ((not I) (/ P V)) ) ) (defun OhmsLawVIR (V R I) (cond ((not V) (* R I)) ((not R) (/ V I)) ((not I) (/ V R)) ) ) (defun OhmsLawPIR (P I R) (cond ((not P) (* (* I I) R)) ((not R) (/ P (* I I))) ((not I) (sqrt (/ P R))) ) ) ;; solve for S given 2 of the remaining 3 variables ;; S = string "P" "V" "R" "I" ;; should have error checking (defun OhmsLaw? (S P V R I) (setq S (strcase S)) (cond ((= S "P") ; return Power/Watts (cond ((not R) (* V I)) ((not V) (* (* I I) R)) ((not I) (/ (* V V) R)) ) ) ((= S "V") ; return Volts/EMF (cond ((not P) (* R I)) ((not R) (/ P I)) ((not I) (sqrt (* P R))) ) ) ((= S "R") ; return Resistance/Ohms (cond ((not P) (/ V I)) ((not I) (/ (* V V) P)) ((not V) (/ P (* I I))) ) ) ((= S "I") ; return Inductance/Amps (cond ((not P) (/ V R)) ((not R) (/ P V)) ((not V) (sqrt (/ P R))) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 7, 2009 Author Share Posted June 7, 2009 WOW! That is excellent CAB. Although I had tested the ones I had posted and found that they work OK, This is much more thorough. I seem to things in a simple format and build around it, But yours would make the coding much shorter. Thank You Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 7, 2009 Author Share Posted June 7, 2009 CAB, Should this ((= S "V") ; return Volts/EMF (cond ((not P) (* R I)) ((not R) (/ P I)) ((not [color=red]V[/color]) (sqrt (* P R))) ) ) Be this? ((= S "V") ; return Volts/EMF (cond ((not P) (* R I)) ((not R) (/ P I)) ((not [color=red]I[/color]) (sqrt (* P R))) ) ) Quote Link to comment Share on other sites More sharing options...
CAB Posted June 7, 2009 Share Posted June 7, 2009 Yes, you are correct. As I typed them up ASAP and went off to tennis & just posted them when I returned, too tired to test them. I'm cleaned up and looking for dinner so enjoy. I'll fix the code in the post per your catch. Thanks. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 7, 2009 Author Share Posted June 7, 2009 I am still reviewing the code so I can fully understand it. I need to see how this code would fit into my original approach. I have not made up my mind as how to do the interface of the DCL, But it will be interesting. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2009 Share Posted June 7, 2009 I can visualise a popup_list for selection of Target Quantity, and four list boxes for variable Entry... keeping things clean an' simple Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.