Tomás Coiro | 21 May 2013 03:38
Picon
Favicon

Bug in PLaneT?

Maybe there's something i don't understand, but PLaneT is telling me that the way to require a package i've put there is:
(require (planet |tomcoiro/Doodle Draw:1:1/lang|))


But putting that in DrRacket tells me it's an ill-formed package name, (possibly because i've put the package with spaces?).
Also there seems to be no way to either delete a package or change it's name, so if that's the problem i don't know how i could fix it.


If it helps, the package page is here http://planet.racket-lang.org/display.ss?package=Doodle%20Draw.plt&owner=tomcoiro


Although you can search it in Miscellaneous in the PLaneT page.


Is there anything I'm missing?


docs are still incomplete, an example program would be something like
#lang s-exp (planet |tomcoiro/Doodle Draw:1:1/lang|)
500 500
(180 280 183 268 186 256 189 244)
(191 244 290 244 300 230 339 245)
(340 246 350 290 360 300 355 210)
(353 210 370 207 380 196 375 193)
(375 193 310 220 190 220 164 205)
(164 205 135 194 135 265 153 275)
(153 275 168 275 170 180 150 190)
(149 190 122 214 142 204 85 240)
(86 240 100 247 125 233 140 238)
(show "Picasso's Dog")


I'd hope that would work with the way it currently is written.


Thanks in advance and thanks to Robby for answering my last question.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Zelah Hutchinson | 21 May 2013 02:48
Favicon
Gravatar

multiple instances of compiled for distribution software

So I think I have a handle on how to run multiple instances of a compiled program under Mac OS. I should be able to catch the command-n keyboard input in my compiled application. But I run into a similar problem when I work in Windows OS. I compile my source code for distribution. When I double click the application icon for a second time, I still only get one instance of the program. This seems like unusual behavior under Windows. What should I do here to obtain multiple instances?
Try FREE IM ToolPack at www.imtoolpack.com
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Guillaume Marceau | 21 May 2013 00:08
Picon
Gravatar

rho-contracts.js: Racket-style contracts for plain JavaScript

Hi all, 


In case this might interest some folks here. I now work for a start up in New York. We're doing physics-based analysis of green buildings. I just received permission to release our JavaScript implementation of Racket's contracts under an open source license, MPL to be precise.


After some fiddling, I was able to create a syntax that's readable enough (I hope). Here is the `derive` function wrapped in a contract:

var c = require('contract')

// define the contract that's used below (since it's used twice):
c.numberToNumber = c.fun( { x: c.number } ).returns(c.number)

// derive: returns a function that is the numerically-computed derivative
//         of the given function.
var derive =
  /* This is the specification: */
  c.fun( { fn:     c.numberToNumber },
         { deltaX: c.number         } )
   .returns(c.numberToNumber)
   .wrap(
         /* And the implementation goes here: */
         function(fn, deltaX) {
           return function(x) {
            return (fn(x+deltaX/2) - fn(x-deltaX/2))/deltaX
           }
         })

Once the contract is in place, you get the kind of error message you always wanted to have in JavaScript, but never could, such as the basic "wrong number of arguments.", and you also get contract error with blame (though only function-level blame, not between-module blame):

  // Error: forgetting an argument:
  > derive(quadratic)
  ContractError: Wrong number of arguments, expected 2 but got 1

  // Error: calling with the arguments flipped:
  > derive(1.0, quadratic)
  ContractError: Expected fun, but got 1
  For the `fn` argument of the call.

  // Error: calling with the wrong kind of function:
  > var d = derive(function(x) { return "**" + x + "**" }, 1.0)

  // The contract-checking shell is now installed around `fn` inside of `d`;
  // throws an error when called:
  > d(100)
  ContractError: `fn()` broke its contract
  Expected number, but got '**100.5**'
  for the return value of the call.


There is also support for placing contract on whole module at a time. Notably, the contract library itself is wrapped with contracts, as it should:


This has been in production at sefaira.com for about a year now. We're really happy to have a piece of Racket-lore be our first open source release. Hopefully there will be more.


Best,

Guillaume





____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Paul Leger | 20 May 2013 10:32
Picon

[Typed Racket] define-predicate for union with functions

Hi all,
      Maybe, this question is very easy. In the following code, I try defining a predicate for T2, but I cannot because T1 it is a function.

(define-type T1 (Symbol -> Any) )
(define-type T2 (U Symbol Number T1))

;(define-predicate T1? Procedure) ;this line is useless

(define-predicate T2? T2)

> Type Checker: Type T2 could not be converted to a contract. in: T2

My unsuccessful answer is:
  (define-type T2 (U Symbol Number Procedure))

I do not like it because I lose the relationship between T1 and T2. Are there some possibility

Thank in advance,
Paul
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Tomás Coiro | 20 May 2013 02:17
Picon
Favicon

Any reason the canvas is still blank?

#lang racket/gui
(define bitmap (make-parameter #f))
(define dc (make-parameter #f))
(define path (make-parameter #f))

(parameterize* ((bitmap (make-bitmap 500 500 #f))
(dc (let ((temp (new bitmap-dc% (bitmap (bitmap)))))
(send temp set-pen "black" 2 'solid)
temp))
(path (new dc-path%)))
(define frame (new frame% [min-width (send (bitmap) get-width)]
[min-height (send (bitmap) get-height)]
[label "test"]))
(send (path) move-to 50 50)
(send (path) line-to 250 250)
(send (dc) draw-path (path))
(define canvas (new canvas% [parent frame]))
(send (send canvas get-dc) draw-bitmap (bitmap) 0 0)
(send frame show #t))


I don't know what i am doing wrong, the bitmap is drawn, if i return it i get the line all fine, the problem is that the frame either doesn't get updated or never tries to draw. Is this a bug in canvas% or am I doing something terribly wrong?
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Zelah Hutchinson | 20 May 2013 02:10
Favicon
Gravatar

multiple instances of compiled for distribution software

I am curious as to whether it would be possible to run multiple instances of a compiled Racket program. If so, then how may I do this? When I try to run the program twice by double clicking in Mac OS, I still only get one running process. This seems like a very serious limitation. Is there a way around this?

Free 3D Marine Aquarium Screensaver
Watch dolphins, sharks & orcas on your desktop!Check it out at www.inbox.com/marineaquarium
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Nathan Campos | 19 May 2013 19:16
Gravatar

Compiling Racket for Command-Line Use Only

Hello,
    I was thinking about using Racket in my HP Jornada 720 (running Linux of course) just for fun, since it's a cool little machine. The problem is that Racket requires FLTK and a all the stuff to run the graphical environment and libraries, which will make a process a lot harder, since I'll have to compile all the X11 stuff, then compile FLTK, then Racket.

    Since all the projects I'll run there are going to be built for command-line, is there any flag I can set to make Racket compile only the command-line stuff and ignore the graphical part?
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Patrick Sweetman | 16 May 2013 14:30
Picon

Problem Stream with alternating values

I'm doing this problem:

6. Write a stream dan-then-dog, where the elements of the stream
alternate between the strings "dan.jpg" and "dog.jpg" (starting with
"dan.jpg"). More specically, dan-then-dog should be a thunk that when
called produces a pair of "dan.jpg" and a thunk that when called
produces a pair of "dog.jpg" and a thunk that when called... etc. Sample
solution: 4 lines.

and I cannot for the life of me understand why the following code does
not produce a properly thunked stream. It evaluates the entries until it
runs out of memory

(define dan "dan.jpg")
(define dog "dog.jpg")

(define (dan-then-dog)
  (define (H1 st0 b0)
    (cond
      [(= b0 1) (H1 (stream-cons dan st0) 0)]
      [else     (H1 (stream-cons dog st0) 1)]
      )
    )
  (H1 empty-stream 1))

Can somebody please explain why my understanding of Racket streams is
faulty?

Thanks,
Patrick Sweetman
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Danny Heap | 17 May 2013 22:36
Picon
Favicon

classroom response system

A colleague has developed a classroom response tool that allows
students to download exercises, write solutions, and then either
visualize the execution of their solution or run unit tests, and then
submit their solution.  The instructor can display a histogram of of
the submissions that passed various tests, and then sample some of the
interesting examples to discuss with the class (all this assumes
wireless coverage for the classroom).

This is currently implemented for Python, but my colleague wants to
extend it to other languages.  He has a student looking into the
feasibility of implementing it for DrRacket, with the rough idea
being:

	-- Students and instructors run local instances of DrRacket
           (hence access to the Stepper for student languages)
	-- Run the tests either client- or server-side in a sandbox
	-- Get files to/from DrRacket to server somehow

Since either students or the instructor will want to load files that
are stored remotely (either starter code for exercises or student
submissions), we're trying to figure out how DrRacket can open code
that lives at a URL in the definitions pane.  Any suggestions are very
welcome.  Also, anyone who is curious about the project is welcome to
contact Andrew Petersen <andrew.petersen@...>.

--

-- 
Danny Heap
BA4270			416-978-5899
heap@...	http://www.cs.utoronto.ca/~heap
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Nick Shelley | 16 May 2013 22:12
Picon

Duplicating output from a system call

I have a script that runs some automated tests and logs the results to the console. The tests can take 10+ minutes, so logging steps to the console is informative. I'm using Racket to run the script with (system ...) and parse the logs and report pass/failure, but to do that I have to capture the logs. I spent about an hour in the port docs and can't figure out how to both log to the console and capture the logs in Racket for further processing (although I'm really good at missing the obvious).

My current workaround is to use the tee command when running the script and then read in and process the file afterwords, but I was wondering if there is a more direct way to do this in Racket.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
J. Ian Johnson | 16 May 2013 21:43
Favicon

Re: RSound in ubuntu only works with diagnose-sound-playing - can't choose library?

I get that aplay is undefined. I'm just doing a (require (planet clements/rsound)). Actually, here it is in
its entirety. The rsound use is in "notice."

https://gist.github.com/ianj/5594474

-Ian
----- Original Message -----
From: "John Clements" <clements <at> brinckerhoff.org>
To: "J. Ian Johnson" <ianj <at> ccs.neu.edu>
Cc: "users" <users <at> racket-lang.org>
Sent: Thursday, May 16, 2013 3:01:28 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] RSound in ubuntu only works with diagnose-sound-playing - can't choose library?

On May 16, 2013, at 11:27 AM, J. Ian Johnson wrote:

> It was 44.1K, but now that I try to reproduce it today (previously had headphones plugged in), it plays no
sound at all.
> I noticed that diagnose-sound-playing does not restore host-api to what it was before the call.

Grr… Mac OS X has 99 problems, but reliable sound-playing ain't one.

I'm not entirely surprised to hear this, although I'm more familiar with the problem on Windows.

Per your suggestion, I've changed the parameter mutation to a parameterize… not that that would affect
your problem at all.

For reference, can you play a sound with 'aplay' (iirc, that's the built-in ALSA player) ?

If you're looking for a sound, you might choose rsound's ./contrib/drum-samples/crash-cymbal.wav .

Thanks again for your help with what I'm sure was just supposed to be a 30-second project.

John

> -Ian
> ----- Original Message -----
> From: "John Clements" <clements <at> brinckerhoff.org>
> To: "J. Ian Johnson" <ianj <at> ccs.neu.edu>
> Cc: "users" <users <at> racket-lang.org>
> Sent: Thursday, May 16, 2013 2:18:48 PM GMT -05:00 US/Canada Eastern
> Subject: Re: [racket] RSound in ubuntu only works with diagnose-sound-playing - can't choose library?
> 
> 
> On May 15, 2013, at 5:18 PM, J. Ian Johnson wrote:
> 
>> Mostly towards John Clements:
>> 
>> I thought I'd take a look at RSound to make a little "do X for 30 seconds *beep* wait 10 seconds *beep*
[repeat]" program. Trying (play ding) gets me the stuff before the "found 2 host APIs" with no sound.
Running diagnose-sound-playing gets me a beep after the "trying api paALSA" but nothing afterwards.
There isn't any documentation for setting the API to just use paALSA, so... what might be going on here? I'm
running xfce 4.10 - xubuntu 12.10 64 bit.
> 
> You're right, there's an undocumented function for setting the api, and also for querying the set of all
available APIs.
> 
> I've added documentation for that, but not pushed it yet.
> 
> In the meantime, you can choose the host API explicitly, using 
> 
> (host-api 'paALSA)
> 
> I don't personally expect this to solve your problem, given what you've said, but I'm curious: did the beep
you heard occur when trying to play at 44.1K, or at 48K?
> 
> Thanks for your help!
> 
> John
> 
>> 
>> I have all the pulseaudio modules that aptitude listed.
>> 
>> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
>> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
>> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
>> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed :
Input/output error(5)
>> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed :
Input/output error(5)
>> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed :
Input/output error(5)
>> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed :
Input/output error(5)
>> ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
>> Cannot connect to server socket err = No such file or directory
>> Cannot connect to server request channel
>> jack server is not running or cannot be started
>> Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from
~/.fonts.conf is deprecated.
>> found 2 host API(s): (paALSA paOSS)
>> trying each one in turn.
>> trying api paALSA:
>> trying to play at sample rate 44100.0:
>> ...finished.
>> trying to play at sample rate 48000.0:
>> Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1670
>> Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1830
>> Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams,
StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2096
>> Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters,
sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 2764
>> playing sound failed with message: "pa-open-stream: Device unavailable"
>> trying api paOSS:
>> trying to play at sample rate 44100.0:
>> playing sound failed with message: "stream-choose: no devices available in current API paOSS with
100.0ms latency or less."
>> trying to play at sample rate 48000.0:
>> playing sound failed with message: "stream-choose: no devices available in current API paOSS with
100.0ms latency or less."
>> If playback at 44100.0 failed and playback at another sample rate
>> succeeded using Windows 7, you probably need to manually set the 
>> sample rate of that playback device to 44100 Hz, by right-clicking 
>> on the volume icon and then digging through menus (properties, advanced).
>> 
>> -Ian
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Gmane