Dr Scheme example

mister-fett -1 Tallied Votes 286 Views Share

Since no one has posted in this forum as of yet, I decided to tap out a quick scheme. This program, when run through the Mr Ed part of dr scheme available from www.drscheme.org , will cause a window to pop up with text and a button. By clicking the button, the text changes, so does the window, and so does the location of the window. Does anyone know what Dr Scheme is besides me on this forum? (there have to be some out of 16,000 users!)

(define start (instantiate frame% ("Welcome to the land")(x 50)(y 50)(height 300)(width 600)))
(define line1 (instantiate message% ("This is a game, and you find yourself in a room" start)))
(define line2 (instantiate message% ("in this room are two things: A sword, and a wand." start)))
(define line3 (instantiate message% ("Obvious exits are north and east." start)))
(instantiate button% () (label "Grab Sword")(parent start)
  (callback (lambda (button event)(send start show #f)(send sword1 show #t))))
(instantiate button% () (label "Grab Wand")(parent start)
  (callback (lambda (button event)(send start show #f)(send sword1 show #t))))
(send start show #t)
(define sword1 (instantiate frame% ("This is a test")(x 100)(y 100)(height 500)(width 800)))
(define msg (instantiate message% ("This whole thing was just a test, so I am not going to complete the game! (sorry!)" sword1)))
dstern 0 Unverified User

I just joined, and am a scheme programmer. So don't think you are all alone here!

Dani 4,084 The Queen of DaniWeb Administrator Featured Poster Premium Member

I have some scheme experience as well, from a computer science programming languages course I took. No experience with Dr. Scheme though. Lambda! Lambda! Lambda!

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Looks a little like the old goofy LISP!

bexta87 0 Newbie Poster

i'm doing scheme at university... and i need some scheme code to convert a decimal number to binary for an exercise we're doing. does anyone have any ideas?

mister-fett 0 Light Poster

I am now in contact with bexta87.
Does anyone else on this forum know scheme?

Junkbone 0 Newbie Poster

1) It looks like LISP because it is LISP. Scheme is a very minimalist version of Common Lisp, and DrScheme is an implementation with some goodies added, such as the GUI library that mr. Fett is using in that example. So you could say PLT scheme is LISP's cousin.
2) As for bexta87's question (although it's a little late for him to do anything iwht the answer), it would depend on your implementation. I know PLT Scheme has a procedure that would do that for you. For more restrictive implementations, you may have to resort to logarithm rules (log base 2 of x equals ln of x over ln of 2) to figure out what order of magnitude you're talking about, then compare it to the next-lowest power of two, if our number is lower, the bit is a zero, if it's higher, the bit is a one and subtract the power of two from our number. Then repeat the comparision process until you get down to 2^0.

nwest 0 Newbie Poster

i want to take a list's depth i write a code but it is not true can you help about this
(define (E11 lst)
(if (null? lst)
1
(if (list? (car lst))
(max (+ 1 (E11 (car lst))))
(E11 (cdr lst)))))

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Welcome to the internet, nwest.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.