You are not logged in.

Stefano

Praktikant

  • "Stefano" is male
  • "Stefano" started this thread

Posts: 8

Date of registration: Nov 28th 2011

1

Thursday, December 15th 2011, 1:04pm

scheme 8 Übungblatt

hallo,
ich habe probleme mit der Orientieren Objekt in die Aufgabe 1 und 2 in der 8 Übungblatt, wer kann mich bitte helfen mit der Lösung
danke.

SammysHP

Forenwolf

  • "SammysHP" is male

Posts: 712

Date of registration: Oct 11th 2010

Location: Celle

Occupation: Informatiker

2

Thursday, December 15th 2011, 1:54pm

Objektorientiert, keine orientierten Objekte. ;)

Wo genau hast du denn Probleme?

Sinvony

Praktikant

Posts: 17

Date of registration: Oct 12th 2011

3

Thursday, December 15th 2011, 2:25pm

Bei Aufgabe 1 könnte ich dir weiterhelfen.

Bei Aufgabe 2 habe ich leider selbst Probleme. Vielleicht kann mir ja jemand erklären, was genau "play" überhaupt machen soll, bzw. wie ich die Methode ohne "make-turn" verwende =S
(Aufgabenblatt: http://www.psue.uni-hannover.de/wise2011…ung/Blatt08.pdf)

Stefano

Praktikant

  • "Stefano" is male
  • "Stefano" started this thread

Posts: 8

Date of registration: Nov 28th 2011

4

Thursday, December 15th 2011, 2:54pm

bei der erste und die zweite aufgabe ich verstehe nicht wie kann ich die methoden impliementieren.

SammysHP

Forenwolf

  • "SammysHP" is male

Posts: 712

Date of registration: Oct 11th 2010

Location: Celle

Occupation: Informatiker

5

Thursday, December 15th 2011, 3:29pm

Bei Aufgabe 2 habe ich leider selbst Probleme. Vielleicht kann mir ja jemand erklären, was genau "play" überhaupt machen soll, bzw. wie ich die Methode ohne "make-turn" verwende =S

Steht eigentlich ziemlich genau drin, was (play) machen soll, nämlich

Quoted

Diese ruft auf der aktuellen Instanz, also self, die Methode (make-turn) auf, bis das Spiel daraufhin auf entweder (won?) oder (lost?) mit #t antwortet.


bei der erste und die zweite aufgabe ich verstehe nicht wie kann ich die methoden impliementieren.

Schau dir die Vorlesungs- und Übungsbeispiele an, da wurde das ziemlich ausführlich genutzt.

This post has been edited 1 times, last edit by "SammysHP" (Dec 15th 2011, 3:30pm)


Jhonny

Praktikant

Posts: 13

Date of registration: Sep 30th 2011

6

Thursday, December 15th 2011, 3:58pm

Ich habe ein komisches Problem. Ich habe ein funktionierendes Programm geschrieben, welches auch die ganze Zeit perfekt lief, bis irgendwann einfach so eine Fehlermeldung auftauchte, ohne das ich etwas geändert habe.
Selbst neustarten bringt nichts, wenn ich aber mein Programm genau so wie es diese Fehlermeldung erzeugt in einen neuen Tab kopiere, funktioniert es dort wieder...

Hier mal die Fehlermeldung:


Source code

1
OO-Pack.rkt:2:0: module: illegal use (not at top-level) in: (module OO-pack scheme (provide create-instance instance? Root send send-msg send/safe send-msg/safe class if if-true if-false) (define (make-instance) (mcons (quote instance) (mcons #f (quote ())))) (define (instance? x) (and (mpair? x) (eq? (mcar x) (quote instance)))) (define (instance-class instance) (mcar (mcdr instance))) (define (set-instance-class! instance class) (set-mcar! (mcdr instance) class)) (define (create-instance class-maker . args) (let* ((instance (make-instance)) (class (class-maker instance))) (set-instance-class! instance class) (let ((init (get-method (quote init) instance))) (if (method? init) (with-handlers ((exn:fail:contract:arity? (lambda (exn) (raise (make-exn (string-append (format "init class ~s: " (car (send-msg instance (quote type)))) (exn-message exn)) (exn-continuation-marks exn)))))) (apply init args)) #f)) instance)) (define (make-class classname methods super-class) (cond ((not (symbol? classname)) (error "bad classname" classname)) ((not (method-list? methods)) (error "bad method list" methods)) ((not (instance? super-class)) (error "bad super-class" super-class)) (else (lambda (message) (cond ((eq? message (quote type)) (lambda () (cons classname (send-msg super-class (quote type))))) ((eq? message (quote methods)) (lambda () (remove-duplicates (append (reverse (method-names methods)) (send-msg super-class (quote methods)))))) (else (let ((entry (method-lookup message methods))) (if entry (cadr entry) (get-method message super-class))))))))) (define (class? x) (procedure? x)) (define (->class x) (cond ((instance? x) (instance-class x)) ((class? x) x) (else (raise-user-error "I don't know how to make a class from" x)))) (define (make-methods . args) (define (helper lst result) (cond ((null? lst) result) ((null? (cdr lst)) (error "unmatched method (name,proc) pair")) ((not (symbol? (car lst))) (error "invalid method name" (car lst))) ((not (procedure? (cadr lst))) (error "invalid method procedure" (cadr lst))) (else (helper (cddr lst) (cons (list (car lst) (cadr lst)) result))))) (cons (quote methods) (helper args (quote ())))) (define (method-list? methods) (and (pair? methods) (eq? (car methods) (quote methods)))) (define (method-lookup message methods) (assq message (cdr methods))) (define (method-names methods) (map car (cdr methods))) (define (Root self) (lambda (message) (cond ((eq? message (quote init)) (lambda () (quote ok))) ((eq? message (quote inspect)) (lambda () (quote ok))) ((eq? message (quote type)) (lambda () (list (quote Root)))) ((eq? message (quote show)) (lambda () (list (quote instance) (car (send-msg self (quote type)))))) ((eq? message (quote methods)) (lambda () (list (quote inspect) (quote init) (quote is-a) (quote type) (quote show) (quote methods)))) ((eq? message (quote is-a)) (lambda (type) (list? (memq type (send-msg self (quote type)))))) (else (quote NO-METHOD))))) (define (send-msg object message . args) (if (instance? object) (let ((method (with-handlers ((exn:fail:user? (lambda (exn) (error (quote send-msg) (format "expects a class object with method ~s: ~s" message object))))) (get-method message object)))) (cond ((method? method) (apply method args)) (else (error (quote send-msg) "expects class object  with method ~s: class ~s" message (car (send-msg object (quote type))))))) (error (quote send-msg) (format "expects a class object with method ~s: ~s" message object)))) (define (send-msg/safe default object message . args) (if (instance? object) (let ((method (with-handlers ((exn:fail:user? (lambda (exn) (error (quote send-msg/safe) (format "expects a class object with method ~s: ~s" message object))))) (get-method message object)))) (cond ((method? method) (apply method args)) (else default))) (error (quote send-msg) (format "expects a class object with method ~s: ~s" message object)))) (define (get-method message object) ((->class object) message)) (define (method? x) (procedure? x)) (define (remove-duplicates lst) (if (null? lst) (quote ()) (cons (car lst) (remove-duplicates (filter (lambda (x) (not (eq? x (car lst)))) lst))))) (define-syntax (if stx) (syntax-case stx (quote) ((src-if bed true) (syntax (cond (bed true)))) ((src-if bed true . false) (syntax (cond (bed true) (else . false)))))) (define-syntax (if-true stx) (syntax-case stx (quote) ((src-if bed . true) (syntax (cond (bed . true)))))) (define-syntax (if-false stx) (syntax-case stx (quote) ((src-if bed . true) (syntax (cond ((not bed) . true)))))) (define-syntax (method-expand stx) (syntax-case stx () ((_ result ()) (syntax (make-methods . result))) ((_ result (name . rest)) (syntax (method-expand ((quote name) name . result) rest))))) (define-syntax (let-expand stx) (syntax-case stx () ((_ last result () . body) (syntax (letrec (last . result) . body))) ((_ last result (first . rest) . body) (syntax (let-expand last (first . result) rest . body))))) (define-syntax (send stx) (syntax-case stx (quote) ((src-send object (quote message) . arguments) (syntax/loc stx (src-send object message . arguments))) ((src-send src-object message . arguments) (cond ((identifier? (syntax message)) (quasisyntax/loc stx (let ((object src-object)) (if (instance? object) (let ((method (get-method (quote message) object))) (cond ((method? method) (unsyntax (syntax/loc stx (method . arguments)))) (else (raise-syntax-error (quote send) (format "expects class object with method ~s: <#class ~s>" (quote message) (car (send-msg object (quote type)))) (syntax (unsyntax (syntax/loc stx send))))))) (raise-syntax-error (quote send) (format "expects class object with method ~s: ~s" (quote message) object) (syntax (unsyntax (syntax/loc stx send)))))))) (else (raise-syntax-error #f "expected an message identifier" stx (syntax message))))))) (define-syntax (send/safe stx) (syntax-case stx (quote) ((src-send default object (quote message) . arguments) (syntax/loc stx (src-send default object message . arguments))) ((src-send default src-object message . arguments) (cond ((identifier? (syntax message)) (quasisyntax/loc stx (let ((object src-object)) (if (instance? object) (let ((method (get-method (quote message) object))) (cond ((method? method) (unsyntax (syntax/loc stx (method . arguments)))) (else default))) (raise-syntax-error (quote send) (format "expects class object with method ~s: ~s" (quote message) object) (syntax (unsyntax (syntax/loc stx send)))))))) (else (raise-syntax-error #f "expected an message identifier" stx (syntax message))))))) (define-syntax (class ...

This post has been edited 1 times, last edit by "Jhonny" (Dec 15th 2011, 3:59pm)


7

Thursday, December 15th 2011, 6:52pm

Warum werden pro Scheme-Übungsblatt eigentlich zwei Threads eröffnet? ?(

This post has been edited 1 times, last edit by "fragenfrager" (Dec 15th 2011, 6:52pm)


AlexL

Junior Schreiberling

  • "AlexL" is male

Posts: 222

Date of registration: Feb 10th 2008

Location: Walsrode

Occupation: Master Informatik

8

Thursday, December 15th 2011, 11:43pm

weil sie auf völlig verschiedene Inhalte abzielen (in diesem Fall)