Alexander D. Knauth | 24 Jan 19:18 2015

a function for a generalization of permutations for floats without going to +inf.0?

Is there a way to define a function for a generalization of permutations for flonums using gamma?
This doesn’t work because if n is >=171 and k is a float it just returns +inf.0:
#lang racket
(require math/special-functions)
(define (my-factorial x) (gamma (+ x 1)))
(define (my-permutations n k) (/ (my-factorial n) (my-factorial (- n k))))

Is there a better way to do this without it returning +inf.0, or is there a library function anywhere that
does this?

  Racket Users list:

Jens Axel Søgaard | 24 Jan 17:38 2015

Scribble index missing when generating pdf file

Hi All.

The following document when rendered to HTML gives a nice index.
However when rendered to PDF the index page just has the "Index"
header, but the page is otherwise blank.

I use the buttons from within DrRacket to render to two formats.

What am I missing?

#lang scribble/base
 <at> title{Testing index}
 <at> section{First section}
 <at> subsection{A subsection of the first section}
Some  <at> as-index{text}.
 <at> section{Second section}
 <at> (index-section)

/Jens Axel
  Racket Users list:

Daniel Kvasnička | 24 Jan 17:39 2015

Untyped arithmetics performance

Hi, I'm observing the following difference in performance:

> (time (exact->inexact (for/sum ([x (in-range 10000)]) (/ x 10000))))
cpu time: 6 real time: 6 gc time: 0
> (time (exact->inexact (for/sum ([x (in-range 10000)]) (/ x (- 10000 x)))))
cpu time: 3624 real time: 3622 gc time: 39

The difference seems huge to me and I'm wondering whether it's "normal" and what are the right tools to
overcome it.
If I understand it correctly, it's about contract checking and the fact that there is one more math
opeartion involved does not in itself lead to such difference. The division operator needs to be sure that
the outcome of the minus op. is of the right type, is that correct?

If so -- and the increase in time cannot be considered a "bug" -- what is the right way to get around that. I've
employed 2 ways: Typed Racket and switching the portion of code to racket/flonum. Both of these
approaches resulted in big perf. improvement and basically make the computation instant again. Are
these the right, "rackety", solutions? I've also tried to use unchecked ops but Racket 6.1.1 is
constantly segfaulting on me when running this (from my digging I think unsafe-fl/ is what segfaults it):

(time (exact->inexact (for/sum ([x (in-range 10000)]) (unsafe-fl/ (->fl x) (unsafe-fx- 10000 x)))))

  Racket Users list:

Didier Verna | 24 Jan 11:09 2015

[2nd CfP] European Lisp Symposium 2015, April 20-21, London

		 ELS'15 - 8th European Lisp Symposium
		    Goldsmiths College, London, UK

			  April 20-21, 2015

	  Sponsored by EPITA, Franz Inc. and Lispworks Ltd.

Recent news:

- Submission deadline in less than a month now!
- Programme committee has been announced (see below)
- Venue information now available on the web site

The purpose of the European Lisp Symposium is to provide a forum for
the discussion and dissemination of all aspects of design,
implementation and application of any of the Lisp and Lisp-inspired
dialects, including Common Lisp, Scheme, Emacs Lisp, AutoLisp, ISLISP,
Dylan, Clojure, ACL2, ECMAScript, Racket, SKILL, Hop and so on. We
encourage everyone interested in Lisp to participate.

The 8th European Lisp Symposium invites high quality papers about
novel research results, insights and lessons learned from practical
applications and educational perspectives. We also encourage
submissions about known ideas as long as they are presented in a new
setting and/or in a highly elegant way.

Topics include but are not limited to:
(Continue reading)

Jordan Johnson | 24 Jan 02:52 2015

2htdp/image: Silent cropping?

Hi all,

A student of mine noticed yesterday that part of an image was getting truncated. Some further experimentation in BSL yielded this example:

(ellipse 5050 100 'solid 'blue) ; => image with 50 pixels missing at right end
(ellipse 100 5050 'solid 'blue) ; => image with 50 pixels missing at bottom

For both images, the image-{width,height} functions produce 100 and 5050; the library simply doesn't draw the entire ellipse, although click-and-drag highlighting does show the image as having 50 extra blank pixels at the end.

I can't find documentation of the size limits. Is this intended behavior? If so, an error might be more student-friendly.


  Racket Users list:
Alexandr M | 23 Jan 17:48 2015

Very simple animation in #racket/gui

Hello dear community members,

I am trying to build a GUI with a very simple animation - just a moving dot (or vertical line) from the left side of the canvas object to it's right side.

There is a section called "1.7 Animation in Canvases" in the racket documentation:

But it's very short and without examples.

Could you please point me out where to search or maybe give me actual example how to implement this using racket/gui ? I know there are matlab-like plotting libs but I am going to build GUI with a lot of buttons and parameters, I don't need just a plot, that's why I am asking about implementation in #racket/gui environment.

Thank you in advance.

Best regards,
  Racket Users list:
Suzanne Menzel | 23 Jan 17:20 2015

Embedded web server in handin-server: Illegal file access


I’m running the embedded web server for handin-server. It is not allowing access to the submitted files.
The links are present, but clicking on any one directs to an Error page with the message “Illegal file
access”. Here are the entries in the web log: - - [23/Jan/2015:11:18:39 -0500] "GET /favicon.ico HTTP/1.1" - - - - [23/Jan/2015:11:18:42 -0500] "GET
HTTP/1.1" - -

Any suggestions on how to fix this?


  Racket Users list:

Luke Whittlesey | 22 Jan 17:39 2015

typed/racket, promises, and type dispatch


I've been learning TR, but I seem to have gotten myself into a corner that I haven't been able to find a workaround for. I'm looking for some help on how to get TR to perform occurrence typing with promises. Basically I'm trying to dispatch based on type, which works without promises, but fails with promises.

For background, this code works::
---- begin working code ----

#lang typed/racket

(define-type Wire Symbol)
(define Wire? (make-predicate Wire))
(define-type WireVec (Listof Wire))
(define WireVec? (make-predicate WireVec))

;; dispatch based on type
(: Not (case-> (Wire -> Wire)
               (WireVec -> WireVec)))
(define (Not wire*)
  (if (Wire? wire*)
      (Not-wire wire*)
      (Not-wirevec wire*)))

(: Not-wire (Wire -> Wire))
(define (Not-wire w)
  (displayln "received wire")

(: Not-wirevec (WireVec -> WireVec))
(define (Not-wirevec w)
  (displayln "received wirevec")

;; test
(Not 'my-wire)
(Not (list 'a 'b 'c))

;;; printed results are
;received wire
;received wirevec
;'(a b c)

---- end working code ----

When I use the same code as above, but add promises to the basic types, I can no longer create a predicate, so I also can't do occurrence typing. Is there a workaround to be able to perform compile time dispatch based on promise types?

;; define types with promises as well
(define-type Wire (U (Promise Wire) Symbol))
(define Wire? (make-predicate Wire))       ; <-- error
(define-type WireVec (U (Promise WireVec) (Listof Wire)))
(define WireVec? (make-predicate WireVec)) ; <-- error

I understand that a contract can't be generated for something like (Promise Wire), because at runtime a promise can't identify it's payload without forcing it, but it seems like the (Promise Wire) type is available at compile time, so there might be a way to make a compile time dispatch.


  Racket Users list:
Daniel Bastos | 22 Jan 17:37 2015

htdp/2e: on types and popular scripting languages

Near exercise 305, HtDP/2e says that "[in] ISL+ (... and in the currently popular scripting languages) such an informal signature with a definite meaning is acceptable on occasion; do not use it too often, however."

It refers to this definition.

; [List-of Attribute] or [List-of Xexpr.v2] -> Boolean
; is the given value a list of attributes?
(define (list-of-attributes? x)
    [(empty? x) #true]
    [else (local ((define possible-attribute (first x)))
            (cons? possible-attribute))]))

Why "acceptable on occasion"? I don't get the message. What is it saying? Thank you.
  Racket Users list:
Alexandr M | 22 Jan 14:53 2015

Calculating cumulative sum of the list


I am trying to replicate functionality of this code in Python:

in Racket without usage of any libraries.

What would the most optimal / concise way to do it in Racket?

Thank you.

Best regards,
  Racket Users list:
Peter Samarin | 21 Jan 22:21 2015

Define several procedures in a macro

Hi all,

I have yet another macro that uses eval!
And it is obvious from the previous discussion that it can be done without.

By the way, thanks for your answers, they were all very helpful!
(I think by mistake, I sent my thanks to Eli only and not to the whole 
mailing list).

The macro is used to define three procedures with provided name and 
fixed suffixes: "-simulation" "-mc" (for microcontroller) and "-vhdl".
It assembles three symbols that combine the provided name with the 
suffixes, then constructs procedure bodies in a list and finally uses 
eval-define combination to define the three procedures.
I suspect that instead of symbols I should construct identifiers and 
then they can be defined without eval, but have not been able to figure 
out a way to do that.

Here is the construction of the simulator procedure:

(define-syntax define-instruction
   (syntax-rules (sim)
     [(_ (name . args) (sim body-r ...))
        (define name-string (symbol->string 'name))
        (define simulator-name
            name-string "-simulation")))
        (eval `(define (,simulator-name . args)
                 body-r ...)))]))

(define-instruction (hello a b c)
    (+ a b c)))

(hello simulation 1 2 3)
;; > 6


;;; Some context for the interested
The macro is used in a larger system for writing custom processors with 
custom instructions (appication specific instruction processors (ASIPs)).
And the purpose for the macro is to define three procedures that 
represent processor instructions that can be used either to simulate 
instructions in a Racket REPL, to embed the instruction in a custom 
processor in VHDL, and to convert the actual sequence of instructions 
into machine code that can be executed on that processor in hardware.
The last two will be eventually combined

As an alternative, I am also working on an interpreter-like version that 
uses no macros.
  Racket Users list: