Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,716 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,153 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Scheme -- Sqrt not working

 
Reply to this topicStart new topic

Scheme -- Sqrt not working

shiningmer
post 10 May, 2008 - 06:41 AM
Post #1


New D.I.C Head

*
Joined: 10 May, 2008
Posts: 2


My Contributions


Hey!

I'm having a little problem with a program I'm trying to write in Dr Scheme
I wrote
(define (vectornorm t n s)
(sqrt (+ (expt t 2) (expt n 2) (expt s 2)) 1/2))


But it gives error in the square root part. Can anyone help me?

User is offlineProfile CardPM

Go to the top of the page


fluxion
post 17 May, 2008 - 06:20 PM
Post #2


New D.I.C Head

*
Joined: 19 Apr, 2008
Posts: 7


My Contributions


im sure you've already figured this out by now, really simple mistake. but just in case: sqrt takes 1 argument. seems to me that you meant to do (expt value1 1/2) to do the sqrt for you.

the fix is obvious, but im gonna post this to see if the forum does syntax highlighting for scheme tongue.gif

scheme
(define (vectornorm t n s)
(sqrt (+ (expt t 2) (expt n 2) (expt s 2)))


also, i dont know if you had completed the function yet, but your code seems to produce the magnitude rather than a normalized vector

This post has been edited by fluxion: 17 May, 2008 - 06:21 PM
User is offlineProfile CardPM

Go to the top of the page

shiningmer
post 18 May, 2008 - 02:09 AM
Post #3


New D.I.C Head

*
Joined: 10 May, 2008
Posts: 2


My Contributions


QUOTE(fluxion @ 17 May, 2008 - 06:20 PM) *

im sure you've already figured this out by now, really simple mistake. but just in case: sqrt takes 1 argument. seems to me that you meant to do (expt value1 1/2) to do the sqrt for you.

the fix is obvious, but im gonna post this to see if the forum does syntax highlighting for scheme tongue.gif

scheme
(define (vectornorm t n s)
(sqrt (+ (expt t 2) (expt n 2) (expt s 2)))


also, i dont know if you had completed the function yet, but your code seems to produce the magnitude rather than a normalized vector


you're right. when i looked at it again i found my mistake immediately, but thanks anyway! biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/8/08 09:10AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month