Jump to content

Recommended Posts

Posted

Hi,

 

I am a very beginner level student of lisp programming. I am facing lots of difficulty to solve this program. Is there anyone who can solve this program and make me happy.

 

 

LISP : "A program that will take your birth date and month as input and will return your zodiac sign"

Posted

Sounds fun. provide the "zodiac" info here and we will write a code for you.

Posted

Zodiac Info

 

Aries - 21 March – 20 April

Taurus - 21 April – 21 May

Gemini - 22 May – 21 June

Cancer - 22 June – 22 July

Leo - 23 July – 22 August

Virgo - 23 August – 23 September

Libra - 24 September – 23 October

Scorpio - 24 October – 22 November

Sagittarius - 23 November – 21 December

Capricorn - 22 December – 20 January

Aquarius - 21 January – 19 February

Pisces - 20 February – 20 March

 

:D

Posted
Hasan, is this a school assignment?

 

I did write a code for Hasan, now that you mentioned that. I will hold off posting the code then :lol:.

Posted

Hey, No...

 

Don't listen to him. This is not a school assignment. You are making me crazy ::x

Please, Share your code.... I will be happy :D

Posted
"A program that will take your birth date and month as input and will return your zodiac sign"

 

Perhaps :D

(defun c:zodiac ( / day mon )
   (if
       (and
           (setq day (getint "\nBirth Day: "))
           (setq mon (getint "\nBirth Month: "))
       )
       (princ
           (vl-list->string
               (mapcar (function (lambda ( x ) (boole 6 90 x)))
                   (vl-string->list "Px#5/(z 5>3;9z)3=4x")
               )
           )
       )
   )
   (princ)
)

Posted

My comment wasn't meant to offend you. Sorry if you felt it like that.

 

But please keep in mind that you are the one who stated that is learning AutoLISP, so I believe that will benefit much more on the long term if you will post what you designed up to now and request us for suggestions to continue/improve, instead of looking for an already written solutions.

Posted (edited)

Since LM started it, might as well....

 

Following consensus ..... 

 

HTH

Edited by pBe
Posted
lol, I didn't start anything...

 

:lol: I did not mean anything bad by that LM.

 

reading the OPs' reply made me feel guilty. I also made MSasu look bad ..... :oops:

Posted
reading the OPS reply made me feel guilty. I also made MSasu look bad ..... :oops:

 

However, MSasu is right - we aren't here to do school assignments, which clearly, this is.

Posted

Ok. I have got it. Thanks to both Lee Mac & pBe :notworthy:

Posted

@pBe: Please, don't worry, my friend!

 

@Lee Mac: Just hope the OP's teacher (disclaimer: if we were right in this assumption, for sure) have a good sense of humor!

Posted
Perhaps :D

(
)

 

:lol: :lol: You did what the OP asked

Posted

I guess its too late for me now... besides i haven't tested the code thoroughly . :)

Posted

If I were to write this function, I would proceed along the following lines:

 

  • Continuously prompt the user for an integer day number until either a null input is received (i.e. the user pressed Enter) or the input is between 1 and 31 (while / getint).

 

  • If a valid day number has been entered, continuously prompt the user for an integer month number until either a null input is received or the input is between 1 and 12 (while / getint).

 

  • If a valid month number has been entered, convert the day/month to a 'base-31' number, i.e. (month*31)+day

 

  • Use a predefined list of zodiac signs complete with the date ranges in their base-31 equivalents, e.g.:
    (
       (032 051 "Capricorn")
       (052 081 "Aquarius")
       (082 113 "Pisces")
       (114 144 "Aries")
       (145 176 "Taurus")
       (177 207 "Gemini")
       (208 239 "Cancer")
       (240 270 "Leo")
       (271 302 "Virgo")
       (303 333 "Libra")
       (334 363 "Scorpio")
       (364 393 "Sagittarius")
       (394 403 "Capricorn")
    )


 

  • Use the vl-some function to compare the day/month input with the number ranges in the list and return the zodiac sign (caddr) if the input falls within the range.

Now you just need to convert the above operations into AutoLISP code.

Posted
If I were to write this function, I would proceed along the following lines:

 

..... convert the day/month to a 'base-31' number, i.e. (month*31)+day.....

 

i just tried to write it the way you described LM. So simple, its crazy.... :lol:

 

You and your Math degree :reallymad:

 

Cheers :beer:

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...