Hasan Faruk Posted April 24, 2013 Posted April 24, 2013 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" Quote
pBe Posted April 24, 2013 Posted April 24, 2013 Sounds fun. provide the "zodiac" info here and we will write a code for you. Quote
Hasan Faruk Posted April 24, 2013 Author Posted April 24, 2013 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 Quote
pBe Posted April 24, 2013 Posted April 24, 2013 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 . Quote
Hasan Faruk Posted April 24, 2013 Author Posted April 24, 2013 Hey, No... Don't listen to him. This is not a school assignment. You are making me crazy : Please, Share your code.... I will be happy Quote
Lee Mac Posted April 24, 2013 Posted April 24, 2013 "A program that will take your birth date and month as input and will return your zodiac sign" Perhaps (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) ) Quote
MSasu Posted April 24, 2013 Posted April 24, 2013 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. Quote
pBe Posted April 24, 2013 Posted April 24, 2013 (edited) Since LM started it, might as well.... Following consensus ..... HTH Edited April 24, 2013 by pBe Quote
Lee Mac Posted April 24, 2013 Posted April 24, 2013 Since LM started it lol, I didn't start anything... Quote
pBe Posted April 24, 2013 Posted April 24, 2013 lol, I didn't start anything... I did not mean anything bad by that LM. reading the OPs' reply made me feel guilty. I also made MSasu look bad ..... Quote
Lee Mac Posted April 24, 2013 Posted April 24, 2013 reading the OPS reply made me feel guilty. I also made MSasu look bad ..... However, MSasu is right - we aren't here to do school assignments, which clearly, this is. Quote
Hasan Faruk Posted April 24, 2013 Author Posted April 24, 2013 Ok. I have got it. Thanks to both Lee Mac & pBe Quote
MSasu Posted April 24, 2013 Posted April 24, 2013 @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! Quote
pBe Posted April 24, 2013 Posted April 24, 2013 I guess its too late for me now... besides i haven't tested the code thoroughly . Quote
Lee Mac Posted April 24, 2013 Posted April 24, 2013 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. Quote
pBe Posted April 24, 2013 Posted April 24, 2013 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.... You and your Math degree Cheers Quote
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.