Tundebabzy's Posts
Nairaland Forum › Tundebabzy's Profile › Tundebabzy's Posts
1 2 3 4 5 6 7 8 9 10 11 12 13 (of 13 pages)
oops, tundebabzy:should have been this: (define (func-n n) (define (step-up n1 n2 n3) (+ n1 (* 2 n2) (* 3 n3))) (define (calc counter n1 n2 n3) (if (= n (+ counter 1)) (step-up n1 n2 n3) (calc (+ counter 1) (step-up n1 n2 n3) n1 n2))) (cond [(< n 3) n] [(= n 3) 4] [(= n 4) 11] [(= n 5) 25] [(> n 5) (calc 5 25 11 4)])) n in func-n is now a free variable so i didnt include it in the definition of calc. |
@DonSegmond: this is what i think that snippet should look like with lexical scoping: (define (func-n n) (define (step-up n1 n2 n3) (+ n1 (* 2 n2) (* 3 n3))) (define (calc counter n1 n2 n3) (if (= n (+ counter 1)) (step-up n1 n2 n3) (calc n (+ counter 1) (step-up n1 n2 n3) n1 n2))) (cond [(< n 3) n] [(= n 3) 4] [(= n 4) 11] [(= n 5) 25] [(> n 5) (calc n 5 25 11 4)])) Like i said earlier,i don't know if i'm wrong (but DrScheme does think i am wrong). It seems DrScheme does not allow more than one expression when creating a procedure. Is it a LISP thing or I should just start reading the book all over again? |
@DonSegmond silly me, you were right. i didnt think towards that angle cos i would have been expecting to see an error like this: reference to an identifier before its definition: average. Thanks sorry to bother you again but help me out with this code: ;;A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) ;;+ 2f(n - 2) + 3f(n -3) if n> 3. Write a procedure that computes f by means ;;of a recursive process. Write a procedure that computes f by means of an ;;iterative process. (define (func-n n) ;; f(1),f(2),f(3),f(4),f(5) are already calculated (cond [(< n 3) n] [(= n 3) 4] ;;pre calculated f(3) [(= n 4) 11] ;;pre calculated f(4) [(= n 5) 25] ;;pre calculated f(5) ;; calc will do the calculation from f(6) and above ;; calc consumes ;;*a number n(which is user defined as in f(n), ;;*a number counter (a counter to determine where the program should stop and return, ;;*3 starting numbers to calculate the iteration [(> n 5) (calc n 5 25 11 4)])) (define (calc n counter n1 n2 n3) (if (= n (+ counter 1)) (step-up n1 n2 n3) (calc n (+ counter 1) (step-up n1 n2 n3) n1 n2))) (define (step-up n1 n2 n3) (+ n1 (* 2 n2) (* 3 n3))) I want it written so that i can make use of lexical scoping. You can write it in common LISP, i should be able to understand. i have my own "solution" (it looks right to me) but it didnt work. It gives me the error i mentioned earlier and in this case all the function just in case its different in common LISP, ";;" starts a comment |
i understand lexical scoping. what i dont understand is why that code didnt work |
please help me with this code.It is supposed to be an implementation of lexical scoping The initial code is this: (define (sqrt x) (sqrt-iter 1.0 x)) (define (sqrt-iter guess x) (if (good-enough? guess x) guess (sqrt-iter (improve guess x) x))) (define (good-enough? guess x) (< (abs (- (square guess) x)) 0.001)) (define (improve guess x) (average guess (/ x guess))) Taking advantage of lexical scoping it should be like this: (define (sqrt x) (define (good-enough? guess) (< (abs (- (square guess) x)) 0.001)) (define (improve guess) (average guess (/ x guess))) (define (sqrt-iter guess) (if (good-enough? guess) guess (sqrt-iter (improve guess)))) (sqrt-iter 1.0)) ;;and that is exactly what is in the book i am reading. However, when i run it on DrScheme i get this error: define: expected only one expression for the function body, but found at least one extra part (referring to where improve is being defined) The text book i am using is MIT's 'Structure and Interpretation of Computer Programs' so i'm wondering how can this be wrong. I tried changing the mode of my DrScheme to Advanced mode but still the same error(i'm using beginner mode). Can anyone help me with the problem? |
lol! |
Dual Core:I support 109%. Thats one of my coding philosophies. |
the problem is not complex and can be solved online. i'm sure the problem has already been solved |
kehers is right. I call it the great collapse and it happens when all the contents of a block element are floated. this is my recommendation. Add this code after #mid-left closing tag (i.e after the tag that closes mid-left: <div style="clear: both;"></div> this will clear the float after #mid-left (thats why you have to put it after the closing tag for mid-left. The only problem with this is that semanticists might frown at it because the div does not show any meaning (as in it just seems to be there, no content, nothing) but it does the job and is not harmless. So you could try this. Please lets know if you get the problem solved with any of the suggestions |
sappiel:You could have just ignored the cat calls from the random guy that you can't even see. That is easier than offering to take the guys with the most information with you. Its understandable why kiwi992 left and its understandable why you want to leave. Just in case you have that much influence, pllllllllllllllllllllleeeeeeeeeaaaaaaaaassssssssseeeeeeeeee don't take away the other guys with so much real information that are left on the thread so that the rest of us can learn "About SAP?". Meanwhile, you don't have to leave the forum, you can just ignore the dude. I swear to God, its not that hard. |
Hi divyesh and dacraziest There is nothing wrong in contacting off the forum but sites like this are meant to share information. If we communicate what we know and solve the problem on the forum, you never know how many other people with the same problem will be able to access the solution to such problems from here. So please consider communicating on the forum and help make a lot of nigerians better coders. (Its just a comment so you dont have to take me serious) |
@all: now that we all know that sappiel's comment was rude and unprofessional, can we get back to the topic? Thank you |
@bordeaux as markos said, go through the whole thread. You will get 1 year worth of information and you will definetely find where your skill fits |
try www.4shared.com |
Go to this thread: https://www.nairaland.com/nigeria/topic-149807.0.html Its been running for over a year and you will find practically all the information about SAP that you could ever need (apart from SAP trouble shooting). A lot of inputs are from SAP consultants and gurus (both functional and technical). The thread is 25 pages so you might not be able to read through in 3 hours, that shows the amount of information that you could find there, plus networking opportunities with real SAP professionals both home and abroad. |
@Tomx LISP is still the most suitable language for complex applications and like DonSegmond said earlier, its early implementation was hampered due to its hardware requirements. I am personally attracted to LISP because of its macros which is a program that writes another program which might write another program. Now thats powerful |
@DonSegmond already have its ebook and been reading it for a while. I also have How to Do Programming which is also a nice one and similar plus videos of MIT's Stucture and Interpretation of Computer Programs course lectures. The syntax is quite funny but i'm enjoying it. What part of AI are you into or planning to go into? |
I just started learning Scheme.hard to look at syntax but i was made to believe that it is the best programming language (apart from Python) to learn programming cos it has a lot of concepts of abstraction that are not present in a lot of other popular programming languages. , and i'm interested in AI |
You can also learn Scheme (which is a dialect of LISP) and then use that to enter into java. You can get materials from MIT's OCW (www.ocw.mit.edu). You will have access to MIT(Massachusetts Institute of Technology) undergraduate and graduate courses materials for free and that includes videos and audio recordings. Best of luck |
@felixv you just made BASIS look yummier for me than before. I'll soon get there |
tundeakinyanmi(at)yahoo(dot)com |
@damidre: still bouncing |
if its GMAT, then i'm okay. because i wasnt able to get in touch with dami dre i had to buy some past questions from one guy like that. The questions there are really technical in nature. seems like the guy just went to pack actual MSc past questions for me instead of entrance exam past questions. I wish i saw this earlier cos i was already getting really scared. i'm doing the pgd. I'm an economics graduate trying to cross over. thanks for the info guys. Please what kind of IT questions though? (as in are they like about algorithms or computer general knowledge like parts of a computer, or computer history like 1st,2nd and 3rd generation of computers or programming stuff) |
@pcguru: you didnt have to give out the answer. You are defeating the whole essence of project-euler |
@ asamuel: how do you you prepare for a battle without finding out who you are fighting with, their strenghts and weaknesses? @damidre: the email you posted seems not to be existent. It keeps bouncing |
Help! Time is running out |
Sorry i didnt specify initially: I'm talking of the pgd in computer science |
Hi guys, I need your help. Is there anyone who knows the format for unilag's pgd entrance exam? I tried to find out from the department but the lady i met there told me they dont sell past questions and that i should read GMAT. I dont know but I expected something more , harder (forgive my grammer). |
@cruworld i use java. in java, 4 million falls within comfortable range for int. A hint: You just need a loop. recycle your variables. My code for no 2 was less than 20 lines so believe me you can do it. |
i'm presently at number 7. just keep trying,you'll solve it. |
nice one dhtml but im still laffing at transparent background, lol! |
those guys are just crazy. Nigerian has billions as excess crude money. Instead of using that money to develop the country, states are sharing the money. Now they want to create 10 more liabilities, just a plot to have more to steal God help us |