Comments (10)
That's a regression caused by me (see ce24736). I will push a fix soon, and you should be able to switch back to #lang sicp
after that (feel free to keep using #lang racket
, too!)
from sicp.
Hi Rick,
This is a bit subtle. The language #lang sicp uses mutable pairs while
#lang racket uses immutable pairs.
If you create a list in #lang sicp you will get a list consisting of
mutable pairs (printed as mcons) and
since the segments->painter is expecting a Racket list consisting of
immutable pairs (printed as cons) you get
the error.
Best advice: Use #lang racket to work with the painter language.
/Jens Axel
2016-03-26 12:55 GMT+01:00 Rick van de Loo [email protected]:
Hi,
I ran into a problem while doing exercise 2.49 from SICP. The
segments->painter procedure from prmpnt.scm gives a contract violation if
it's given a list defined in the sicp lang.#lang sicp
(#%require sicp-pict)(define (make-vect x y)
(cons x y))(define (xcor-vect vect)
(car vect))(define (ycor-vect vect)
(cdr vect))(define (make-segment vect-origin-to-start vect-origin-to-end)
(cons vect-origin-to-start vect-origin-to-end))(define outline-segments
(segments->painter
(list ; <- culprit
(make-segment (make-vect 0.0 0.0) (make-vect 0.0 0.99))
(make-segment (make-vect 0.0 0.0) (make-vect 0.99 0.0))
(make-segment (make-vect 0.99 0.0) (make-vect 0.99 0.99))
(make-segment (make-vect 0.0 0.99) (make-vect 0.99 0.99)))))(paint outline-segments)
for-each: contract violation
expected: list?
given: (mcons (mcons '(0.0 . 0.0) '(0.0 . 0.99)) (mcons (mcons '(0.0 . 0.0) '(0.99 . 0.0)) (mcons (mcons '(0.99 . 0.0) '(0.99 . 0.99)) (mcons (mcons '(0.0 . 0.99) '(0.99 . 0.99)) '()))))
argument position: 2ndThe violation occurs here
https://github.com/sicp-lang/sicp/blob/master/sicp-pict/prmpnt.scm#L114.
The snippet above works if instead of using #lang sicp, #lang racket/base
is used.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#4
Jens Axel Søgaard
from sicp.
I'll see if I can get segments->painter to accept both kind of lists.
/Jens Axel
2016-03-26 14:29 GMT+01:00 Jens Axel Søgaard [email protected]:
Hi Rick,
This is a bit subtle. The language #lang sicp uses mutable pairs while
#lang racket uses immutable pairs.
If you create a list in #lang sicp you will get a list consisting of
mutable pairs (printed as mcons) and
since the segments->painter is expecting a Racket list consisting of
immutable pairs (printed as cons) you get
the error.Best advice: Use #lang racket to work with the painter language.
/Jens Axel
2016-03-26 12:55 GMT+01:00 Rick van de Loo [email protected]:
Hi,
I ran into a problem while doing exercise 2.49 from SICP. The
segments->painter procedure from prmpnt.scm gives a contract violation if
it's given a list defined in the sicp lang.#lang sicp
(#%require sicp-pict)(define (make-vect x y)
(cons x y))(define (xcor-vect vect)
(car vect))(define (ycor-vect vect)
(cdr vect))(define (make-segment vect-origin-to-start vect-origin-to-end)
(cons vect-origin-to-start vect-origin-to-end))(define outline-segments
(segments->painter
(list ; <- culprit
(make-segment (make-vect 0.0 0.0) (make-vect 0.0 0.99))
(make-segment (make-vect 0.0 0.0) (make-vect 0.99 0.0))
(make-segment (make-vect 0.99 0.0) (make-vect 0.99 0.99))
(make-segment (make-vect 0.0 0.99) (make-vect 0.99 0.99)))))(paint outline-segments)
for-each: contract violation
expected: list?
given: (mcons (mcons '(0.0 . 0.0) '(0.0 . 0.99)) (mcons (mcons '(0.0 . 0.0) '(0.99 . 0.0)) (mcons (mcons '(0.99 . 0.0) '(0.99 . 0.99)) (mcons (mcons '(0.0 . 0.99) '(0.99 . 0.99)) '()))))
argument position: 2ndThe violation occurs here
https://github.com/sicp-lang/sicp/blob/master/sicp-pict/prmpnt.scm#L114.
The snippet above works if instead of using #lang sicp, #lang racket/base
is used.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#4Jens Axel Søgaard
Jens Axel Søgaard
from sicp.
This commit
0da6a81
fixes the problem.
Update the sicp package either using raco or the DrRacket package manager
to get the changes.
Thanks for the bug report.
/Jens Axel
2016-03-26 14:36 GMT+01:00 Jens Axel Søgaard [email protected]:
I'll see if I can get segments->painter to accept both kind of lists.
/Jens Axel
2016-03-26 14:29 GMT+01:00 Jens Axel Søgaard [email protected]:
Hi Rick,
This is a bit subtle. The language #lang sicp uses mutable pairs while
#lang racket uses immutable pairs.
If you create a list in #lang sicp you will get a list consisting of
mutable pairs (printed as mcons) and
since the segments->painter is expecting a Racket list consisting of
immutable pairs (printed as cons) you get
the error.Best advice: Use #lang racket to work with the painter language.
/Jens Axel
2016-03-26 12:55 GMT+01:00 Rick van de Loo [email protected]:
Hi,
I ran into a problem while doing exercise 2.49 from SICP. The
segments->painter procedure from prmpnt.scm gives a contract violation if
it's given a list defined in the sicp lang.#lang sicp
(#%require sicp-pict)(define (make-vect x y)
(cons x y))(define (xcor-vect vect)
(car vect))(define (ycor-vect vect)
(cdr vect))(define (make-segment vect-origin-to-start vect-origin-to-end)
(cons vect-origin-to-start vect-origin-to-end))(define outline-segments
(segments->painter
(list ; <- culprit
(make-segment (make-vect 0.0 0.0) (make-vect 0.0 0.99))
(make-segment (make-vect 0.0 0.0) (make-vect 0.99 0.0))
(make-segment (make-vect 0.99 0.0) (make-vect 0.99 0.99))
(make-segment (make-vect 0.0 0.99) (make-vect 0.99 0.99)))))(paint outline-segments)
for-each: contract violation
expected: list?
given: (mcons (mcons '(0.0 . 0.0) '(0.0 . 0.99)) (mcons (mcons '(0.0 . 0.0) '(0.99 . 0.0)) (mcons (mcons '(0.99 . 0.0) '(0.99 . 0.99)) (mcons (mcons '(0.0 . 0.99) '(0.99 . 0.99)) '()))))
argument position: 2ndThe violation occurs here
https://github.com/sicp-lang/sicp/blob/master/sicp-pict/prmpnt.scm#L114.
The snippet above works if instead of using #lang sicp, #lang
racket/base is used.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#4Jens Axel Søgaard
Jens Axel Søgaard
Jens Axel Søgaard
from sicp.
Great! Thanks for the quick reply :)
from sicp.
GOOD GRIEF! I spent a whole day wondering what in the world was wrong with my code.
Thank you for the question and the answer. I wish I had checked sooner.
I can concur that declaring #lang racket
instead of #lang sicp
is the fix.
I pushed a commit to my repo, fixing the language declaration, and with details in the commit message.
Use 'racket', not 'sicp' in ex2-44 picture lang file
adityaathalye/sicp@c8b62c3
from sicp.
Hmm. Provided that @soegaard made segments->painter
to accept both mutable and immutable lists, there should not be any problem, right? Can you provide us a code example that leads to a problem?
from sicp.
Hmm. Provided that @soegaard made
segments->painter
to accept both mutable and immutable lists, there should not be any problem, right? Can you provide us a code example that leads to a problem?
Updated my earlier comment to keep things in context: #4 (comment)
from sicp.
I believe this is fixed by 4152068. Closing. Feel free to reopen it if you find any other issues.
from sicp.
I just updated lang-sicp locally and can confirm SHA 4152068 fixes the bug. Thank you!
from sicp.
Related Issues (20)
- paint other image HOT 2
- cons-stream and amb are not documented HOT 1
- even cooler having tests <3 HOT 1
- filter: contract violation expected: list? HOT 3
- Contract for vector-scale should be real?
- Unify sicp-pict/main.rkt and sicp-pict/sicp.rkt HOT 1
- Port picture->painter and load-painter HOT 1
- Setup travis ci and add tests HOT 1
- Error on 3.5.4 Streams and Delayed Evaluation HOT 3
- make sure Racket and R5RS do not mix up badly
- Make top interaction works with R5RS
- Please add the racket topic to this repo HOT 2
- Expression will out of momery when sicp package installed on racket-cs HOT 4
- How does the coordinate mapping work? HOT 3
- segments->painter :: target is not an object HOT 6
- squash-inwards example of the book HOT 11
- SICP not building on the build server HOT 2
- DrRacket can't install the package HOT 4
- SICP package not listed in category “Other Languages in the Racket Environment”
- External links and Contributors links not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sicp.