splay handlers that modify the model, or
mouse handlers that draw to the display, causing the aforementioned display
bugs.
Stephen Bloch
sbloch1...@gmail.com
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from thi
tion you were profiling) down from 22s to 15s. Replacing
> the `index+'s with generic `+' and `assert's (to enforce `Index'
> results) brings the running time down to 2.5s.
Generic ‘+’, not ‘unsafe-fx+’?
Should I be using racket/unsafe/ops at all?
Stephen Bloch
sbl...@adelphi
nas7aldecx7/NxsLBA5573 .
Stephen Bloch
sbl...@adelphi.edu
signature.asc
Description: Message signed with OpenPGP using GPGMail
Racket Users list:
http://lists.racket-lang.org/users
m… but even size 2048 has been
taking hours or days to run.
Stephen Bloch
sbl...@adelphi.edu
signature.asc
Description: Message signed with OpenPGP using GPGMail
Racket Users list:
http://lists.racket-lang.org/users
unction that builds a
random square matrix of a given size, to be handed to all three multiplication
algorithms).
> As Matthias said, if you can share your code, I'd be happy to have a
> look.
Sure. That may take a few hours: I have to run off to class now.
Stephen Bloch
sbl...@adelphi.e
of a graph-coloring problem, and I want to have students plug in their own
algorithms for graph-coloring. C is the adjacency relation, the list of
available colors, a couple of things like that. My students have never heard
of parameterize, but that's the least of my worries right now.
not what you're remembering, but you could take a look at
http://home.adelphi.edu/sbloch/papers/func-imp-testing.pdf
which is one of my slides from a conference talk.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
n to Systematic Program
Design" is a subset of the picturing-programs library used in _Picturing
Programs_, so if you follow the directions in chapter 0.3 of the book, all the
examples in both the book and the MOOC should work.
Dr. Stephen Bloch
Math/CS Dept, Adelphi University
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
n to Systematic Program
Design" is a subset of the picturing-programs library used in _Picturing
Programs_, so if you follow the directions in chapter 0.3 of the book, all the
examples in both the book and the MOOC should work.
Dr. Stephen Bloch
Math/CS Dept, Adelphi University
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
a list of
numbers '(8 7 2)
; (my-function (rest numbers)) whatever type this returns
278
; right answernumber
2783
…
]))
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
nd I could
understand it without worrying about macros :-)
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
is on Scheme or Racket, see
http://docs.oracle.com/javase/1.5.0/docs/api/java/math/RoundingMode.html and
http://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
On Feb 13, 2013, at 12:47 PM, Dmitry Pavlov wrote:
> Hello,
>
> I just figured that there is a thing in Racket coding style
> that bothers me from time to time. That thing have never arised
> in C-style languages.
Right: in C-style languages there's a special "dot" syntax for getting at the
f
this, then find the binary in the "bin" folder and run it, and it
does nothing.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
32-bit binary, and it worked. What puzzles me is why I didn't notice a problem
until today.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
function, writing test cases for it as
usual, and only after it worked, consider moving it inside "f". Unless it
depended on something in the containing function, which it doesn't… no, wait,
it refers to n, the parameter of the outer function. Why? And why doesn't the
de
s skewer%, so the only legal way to build a shish-kebab is
with a skewer at the end.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ld be rewritten as n*n)
step 2: ((n*2) + 300), or if you meant n-squared, ((n*n) + 300)
step 3: (+ (* n 2) 300), or if you meant n-squared, (+ (* n n) 300)
How would you do this for the entire expression?
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
akes it easy to unit-test the
latter function on arbitrary data. Since the former function is only about the
file system, meaningful unit-testing for it it would have to be about how it
handles files that exist, files that don't, unreadable files, files in
unreadable directorie
ambda (n) (+ n 2 (add1 (add1 m))))
(add2 3) ; produces 7
or, if you prefer to do the "let"ting at define-time,
(define add2
(let ((add1 (lambda (n) (+ n 2
(lambda (m) (add1 (add1 m)
(add2 3) ; produces 7
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
I'm also not seeing these crashes in 5.3.1 in Windows in VMWare on my Mac.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
the 'stop' button--'user break' appears, and the animation
> keeps going
> 5. Press CTRL+R
I'm not seeing either of these on my Mac. I'll see if Windows-on-a-Mac is
willing to run today
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
line where they meet -- which, while annoying, would at
least be easier for beginners to understand. And it would mean that (rectangle
1 15 "outline" "black") draws as 1 pixel wide.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
pt Web pages with certain common tags
unterminated: , , , , etc. and there's a reasonable argument
that Racket's XML library should be capable of accepting them too.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
but EXTRA parentheses can never hurt. In Lisp/Scheme/Racket, either
one can hurt.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
in HtDP chapter 6 ten years ago, in part because
of this uncomfortable confusion between imperative and functional programming.
Most of us have been using the functional "image" library instead. For course
materials built on this approach, see
http://www.ccs.neu.edu/home/mat
On Dec 11, 2012, at 9:03 AM, Jens Axel Søgaard wrote:
> 2012/12/11 Stephen Bloch :
>
>> Would it perhaps make more sense for small-primes to contain primes
>> themselves, in increasing order so one can be found by binary search, rather
>> than booleans? The O(1) behavio
(limit)), but perhaps you would
save enough memory to put the limit higher.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
up behavior in Java?
I tried the negations of the same numbers, and they still all end in ".22", as
though it were in round-towards-zero mode, but I queried the rounding mode and
it says it's HALF_EVEN.
The corresponding results in Racket, BTW, are
("0.23" "1.23" "2.23" "3.23" "4.22" "9.22" "17.23" "35.23" "68.22" "130.22"
"250.22")
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
oblem for my computer-architecture
students.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
if you're getting the inexact 4.225 from
somewhere else, again it's not really 4225/1000 so it's already too late to
round it the way you want.
You could work in a student language, where the reader reads decimals as exact
by default :-)
Seriously, I
wn game, and many
Python-first curricula introduce nested for-loops early in order to process
images pixel by pixel.)
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
; the two 65x65 images. This could be acceptable for a game with one or two
> collision detections per frame.
>
> You could improve this *hugely* just by doing some bounding-box computation.
>
> Should I put this code in 2htdp/private/image-more.rkt somewhere?
Sounds useful
> of doing the kinds of things that Scratch makes easy.
And vice versa, of course: there are lots of things that are easy in universe,
but very difficult in Scratch.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
f. It is the bare minimum to really start using it.
Quite true, and I don't even use the "bare minimum" you describe. Not to say
that most of the things you describe don't strike me as incredibly useful
Stephen Bloch
sbl...@adelphi.edu
Racket U
ink of it as a powerful, feature-rich editor; I
think of it as an uncluttered, beginner-friendly editor. Being both of those
things at once is amazingly difficult
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
;to a human being" or "to the time
form"). To distinguish between linear and n*log(n), I would think millions or
tens of millions.
But the Horner's algorithm solution is also shorter code than either of the
others :-)
Stephen Bloch
sbl...@adelphi.edu
nted by repeated squaring, the total
number of multiplications would be O(n log(n)); with Horner's algorithm or your
"values" approach, it's linear.
Horner's algorithm gives us
(lambda (poly x)
(for/fold ([sum 0])
([c (polynomial-coeffs poly)])
(+ c (* sum x
ich of the other expressions resembles it
most closely? (Usually the result of a recursive call.) What would you need
to do to that similar value to get _exactly_ the right answer?
Once you've got an expression that works for this example, try it on other
examples.
Stephen Bloch
sbl
iously, I'd love to teach with some kind of signature system in the language
(not just in comments), but right now we have three or four alternative systems
(contracts, signatures, TR, and probably others), none of which has really had
the pedagogical bugs worked out.
Stephen Blo
a response.
I'm not actually teaching a Racket-based class in those labs this semester, so
I haven't taken the time to track this down to specific examples, nor tried
installing 5.3 to see if the problem goes away. But is there a known
performance or installation problem that would c
ressable machine, and if you tried to
dereference an odd-numbered address, it would crash immediately, as one would
expect of dereferencing a null pointer). And on MANY systems (including
Racket), the floating-point number 0.0 doesn't necessarily resemble the integer
0.
Step
.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ms.com/download/chap25.pdf , which is entitled "Multiple
recursive data". Of course, that chapter assumes that you're already fluent at
writing functions that operate on ONE recursive data type, e.g.
http://picturingprograms.com/download/chap22.pdf and
http://picturingprogram
that are interpreted as procedure calls by the Forth
interpreter (which is in native executable code, but written in advance).
Or are you talking about some kind of JIT compiler?
Stephen Bloch
sbl...@adelphi.edu
who last implemented a Forth system in 1983; I presum
ion: why did matching on "make-posn" work? Shouldn't posn
be exposed in the same way as color?
Or is this something to do with make-color, which does error-checking and has
an optional argument with a default value and all sorts of complicated stuff
that make-posn doesn
quot;. For more related examples, see "map-image" and
"map-image/extra".
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
quot;. For more related examples, see "map-image" and
"map-image/extra".
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
mebody directly involved with DrRacket's development.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
the code is very nearly a rewording of the purpose statement. As a bonus, it's
also more efficient, since "ormap" does short-circuit evaluation: as soon as it
finds an upper-case letter, it stops without looking at the rest of the string.
Another, weirder and less efficient but ev
given symbol at the front of
each of the given words. Maybe a better name would be "cons-each".
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
e he gets the names right.
Interesting idea. It doesn't ensure that he gets the contracts right -- he
still needs to actually TRY the functions for that -- but it will give him an
error message if he gets the names wrong, which is helpful.
Stephen Bloch
Racket Users list:
http://lists.racket-lang.org/users
On Jun 29, 2012, at 10:34 PM, Matthias Felleisen wrote:
>
> On Jun 29, 2012, at 5:30 PM, Stephen Bloch wrote:
>
>> This is a fairly common confusion for my students
>
>
> This is the first time I am encountering this confusion.
Really? You've never had a
> ; interp. (make-editor x h) where x is the x-coordinate of the cat and h is
> the happiness of the cat.
> ; make-editor Number Number -> Vcat
> ; Vcat-Xcat Editor -> Number
> ; Vcat-Hcat Editor -> Number
> ; Vcat-Richting -> String
> ; Vc
ggested in the
past providing a "define-union" form in the student languages. It wouldn't do
very much -- just define a discriminator for the new type as the "or" of the
discriminators for the subtypes -- but it would provide students with a
concrete syn
e not ready for test-driven design yet." I replied "No, you've
got it backwards: the students in your software engineering course MIGHT be
sharp enough and experienced enough to sometimes do without test-driven design;
the freshmen are the ones who nee
You know, whenever the government tries to help people kick the habit, they
call it a "syntax"....
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
anvas dc) (draw canvas dc))".
> However, in the second case the window doesn't update unless draw is called
> from REPL.
Yes, that's because you're only calling draw once, at the time you define
canvas.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
awards for PLT people in one day! Mazeltov!
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
notice that we're not actually USING n anywhere, so we might as well
leave it out:
(define (my-map f lst)
(cond [(empty? lst) empty]
[else (cons (f (first lst)) (my-map f (rest lst)))]))
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
it, then assign my
assistant to clean this room as well as all the rooms I was assigned. My
assistant does the same, and rather than having fewer and fewer rooms left to
clean, we have more and more. In other words, the function calls itself to
solve A LARGER PROBLEM than it itself was given.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ast semester's didn't get to lists at all), so I don't know
how those problems actually work in the classroom. Anybody out there who's
tried them?
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ons: you'll write at
least a hundred of them in the remainder of the semester."
If you have suggestions for other image utilities like this, talk to me
off-list and we can include them in picturing-programs, which has the advantage
of being bundled with DrRacket so there's no separate installation procedure.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
g
extra parameters to fast-expt, making it harder to understand. And, as
somebody else pointed out, the recursion depth is only log_2(n) so it's really
not a concern.
Stephen Bloch
sbl...@adelphi.edu
>
Racket Users list:
http://lists.racket-lang.org/users
otient n 2]))
This reduces O(n) many multiplications to O(log(n)) many multiplications, which
will dwarf most of the other optimizations people have mentioned.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ble difficulty.
For that matter, if you have good reasonably-easy exercises for the C
preprocessor, that would be helpful too.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
this event handler until
the event handler passes all of its test cases in isolation.
My first guess was mismatched parentheses, so I copied and pasted your code
into DrRacket, then inserted a bunch of newlines and tabs so I could spot
mismatches by indentation. The result was clearer,
presumably hasn't gotten to
lists yet. But there are lots of interesting problems to solve on fixed-sized
data, including lots of interactive GUI programs. Eight or ten years ago, one
of my CS1 students got bored with the class assignments and wrote a complete
chess program using structs a
bang verwerker
(check-with editor?)
(on-key edit)
(on-draw )
)
This causes the animation to check immediately after every event to make sure
the "world" is still an editor, and if it isn
an just
return the image of the text, and not worry about overlay or place-image.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
se in the function body is "fixed", then the result will
also be "fixed", i.e. you'll get the same answer every time -- almost certainly
not what you want. However, there may well be SOME things that you want to be
the same every time, such as the color "black", the background scene workspace,
the font size 11, etc.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
an editor instead.
More broadly, you're doing the whole problem the hard way. Why do you need to
know the width of anything? I would do this whole problem without an
image-width, without arithmetic, without a place-image, using the functions in
the 2htdp/image library.
St
. How about
(as Danny suggested) making an image of the left side text, and taking its
width?
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
of these have earned multiple NSF grants,
just as PBD has. Most of these have been presented at national and regional
conferences, just as PBD has. Why isn't PBD one of the options people think of
when they start a conversation about "how to teach CS1"?
ing letters."
What is the contract of your 1 function?
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
ead.
> Following your way of working the answer is (posn-x p) and (posn-y p) because
> P is the struct which holds the position.
"The answer" to what? It's true that (posn-x p) and (posn-y p) are both
reasonable expressions to use; whether they're right answers
ollow its contract because posn-x is supposed to take a
parameter.
"p-x" doesn't follow the contract because it's not defined at all.
"(posn-y u)" doesn't follow the contract because u is a ufo, and posn-y is
supposed to take in a posn.
And so on.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
;s happening. It has nothing to do with subtleties of the
world teachpack; it's a simple bug in your code, related to your switching
between English and Dutch words.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
symbols:
the symbol-table lookup should happen at compile-time (right?), so you're left
with a constant-time pointer comparison at run-time.
Disclaimer: I've implemented only "toy"-scale Schemes myself.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
that
effectively pushes every few seconds, but only every several pushes become a
distinct "commit" record.
A less elaborate version wouldn't log much of anything, but would still
synchronize with a server every few keystrokes.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
at all.
Alternatively, you can use
(require picturing-programs)
which includes all the same functions as 2htdp/image (such as beside, above,
place-image, circle, triangle, rectangle, etc.) as well as some others like
map-image and build-image.
Stephen Bloch
sbl...@adelphi.edu
;if the two-function version makes more
sense to you, do it that way. If the one-function version makes more sense to
you, do it that way." Although for some data structures (e.g. n-ary trees) you
NEED multiple functions.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
On Feb 21, 2012, at 3:18 PM, Roelof Wobben wrote:
> Op 21-2-2012 20:51, Stephen Bloch schreef:
>>
>> On Feb 21, 2012, at 2:43 PM, Roelof Wobben wrote:
>>
>>> But now I get this error message :
>>> unsaved editor>:27:23: function call: expected a fun
f right and wrong answers to
track down where the problem is.
3) Have you used the Stepper to watch what your program is doing?
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
TLY (not
always) produced correct answers.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
On Feb 21, 2012, at 11:40 AM, Matthias Felleisen wrote:
> You are right. We must teach students how to be bad OO programmers in CS2.
> Where else would they learn it? Plus they pay us for it.
No, but we must teach students to read and modify code written by bad OO
programmers.
Stephen
uses null-terminated data structures instead, despite that approach's
practical disadvantages, so students need to learn how to work with them too --
and CS2 seems like an appropriate place to do that. So yes, they WOULD have a
conditional for the outer part.
Stephen Bloch
sbl...@adelphi.edu
cture.
It's a judgment call, which can go different ways in different circumstances.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
the more-legitimate
world of statements.
if (blah == true) {
return true;
}
else {
return false;
}
For those of us forced to teach in Java, CheckStyle has two modules,
SimplifyBooleanExpression and SimplifyBooleanReturn, that catch things like
this.
Stephen Bloch
sbl...@ade
; "green" "blue"
"violet") returns a function acting like "next-color".
One suggestion: I would have mk-fib take in two parameters specifying the
initial values of fib, rather than always making them -1 and 1.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
, because the teacher had decreed "no global
variables". In retrospect, I should have packaged them up into a
record/struct, which would not only make the code cleaner and less error-prone
but also make it easy to simulate multiple instances of the OS.
Stephen Bloch
sbl...@adelphi.e
(if (test? value)
(loop (cons value vs))
vs)
(define (fib-less-than-n n)
(take-while (mk-fib) (lambda (value) (< value n
[I haven't typed this code in and tested it, so there may be typos.]
Stephen Bloch
sbl...@adelphi.edu
__
ows for easy replacement) and see if I can run some meaningful
> comparison tests.
Data are good. It would be very interesting to see whether the burden on the
garbage collector really IS as heavy as you think.
"Premature optimization is the root of all evil" -- somebody somewhere
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
cept on performance. The only way I know of to
implement that is for the bitmap to actually store more than width*height
pixels.
Stephen Bloch
sbl...@adelphi.edu
Racket Users list:
http://lists.racket-lang.org/users
and how to write methods on them;
then Java collection classes and looping over them; etc.
I think this was a lot more concrete and fulfilling than building a
whole lot of different kinds of classes, through polymorphism, class
composition, and recursion, before ever writing a me
).
But in a Roguelike game, you probably want a monospaced font anyway; ligatures
and kerning would only confuse matters.
Stephen Bloch
sbl...@adelphi.edu
_
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
IS program very much, since it only makes one
state change in each case of the "cond". But it would help other
world/universe programs.
I would very much like to see SOME kind of functional-update feature bundled --
whether it comes along with define-str
On Dec 12, 2011, at 10:53 AM, Will Robinson wrote:
> Hello,
>
> I'm trying to do a simple Roguelike game as an exercise in learning the
> language, particularly racket/gui. I'm using draw-text to place characters
> on the screen. Ideally, I'd just call this once and put up huge string full
even need to sort the list; you can just use the relation to
make sure you don't double-count anything.
Stephen Bloch
sbl...@adelphi.edu
_
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
cripting languages would allow you to extract the elements of
p at the same time, e.g. Ruby
myList.subsetsOfSize(2).each { |x,y| ...}
which would take a bit of macro-wrangling in Racket.
Stephen Bloch
sbl...@adelphi.edu
_
For list-related
1 - 100 of 237 matches
Mail list logo