Daniel Bastos | 2 Sep 18:05 2014

missing solution 20.1.2 ex:syn-funcs

Exercise 20.1.2. Argue why the following sentences are legal
definitions:

(define (f x) (x 10))

(define (f x) f)

(define (f x y) (x 'a y 'b))

Solution. The relevant part of the grammar is the following.

  <def> = (define (<var> <var> ...<var>) <exp>)
        | (define <var> <exp>)
        | (define-struct <var> (<var> <var> ...<var>))

(*) First definition

The LHS is a list of <var>, since we find f and x as members of the
list and they're both variables. The RHS is a list consisting of a
<var> and a <num>. That composes an <exp>, satisfying the first form
of <def>. In other words,

  (define (<var> <var>) (<var> <num)) =
  (define (<var> <var>) (<exp> <exp>) =
  (define (<var> <var>) <exp>).

Therefore it's a legal <def>.

(*) Second definition

(Continue reading)

Daniel Bastos | 2 Sep 17:45 2014

missing solution 20.1.1 ex:sem-funcs

A candidate for a solution.

Exercise 20.1.1. Assume the Definitions window in DrScheme contains
(define (f x) x). Identify the values among the following expressions:

(1) (cons f empty)
(2) (f f)
(3) (cons f (cons 10 (cons (f 10) empty)))

Explain why they are values and why the remaining expressions are not
values.

Solution. First we consider (1). Here's the relevant part of the
grammar.

  <lst> = empty | (cons <val> <lst>)

  <val> = <boo> | <sym> | <num> | empty | <lst>
  | <var> (names of defined functions)
  | <prm>

So (1) is a value because it is <lst> of the form (cons <var> empty),
where f is <var> because it is a defined function.

Let's consider (3) before (2). (3) is a list of either <var> or <num>,
so (3) is <val> as well.

Now we consider (2). Here's the relevant part of the grammar.

  <exp>       =    <var>
(Continue reading)

publicityifl | 2 Sep 09:23 2014
Picon

Third call for papers, IFL 2014

Hello,

Please, find below the third call for papers for IFL 2014.
The submission page is now open. The submission date has been
delayed to Sep. 8 2014 anywhere on the world.

Please forward these to anyone you think may be interested.
Apologies for any duplicates you may receive.

best regards,
Jurriaan Hage

---

CALL FOR PAPERS

26th SYMPOSIUM ON IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES - IFL 2014

NORTHEASTERN UNIVERSITY/BOSTON, USA

OCTOBER 1-3, 2014

http://ifl2014.github.io

We are pleased to announce that the 26th edition of the IFL series
will be held at Northeastern University in Boston, USA. The symposium
will be held from 1st to 3rd of October 2014.

Scope
-----
(Continue reading)

publicityifl | 2 Sep 09:23 2014
Picon

Third call for papers, IFL 2014

Hello,

Please, find below the third call for papers for IFL 2014.
The submission page is now open. The submission date has been
delayed to Sep. 8 2014 anywhere on the world.

Please forward these to anyone you think may be interested.
Apologies for any duplicates you may receive.

best regards,
Jurriaan Hage

---

CALL FOR PAPERS

26th SYMPOSIUM ON IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES - IFL 2014

NORTHEASTERN UNIVERSITY/BOSTON, USA

OCTOBER 1-3, 2014

http://ifl2014.github.io

We are pleased to announce that the 26th edition of the IFL series
will be held at Northeastern University in Boston, USA. The symposium
will be held from 1st to 3rd of October 2014.

Scope
-----
(Continue reading)

Matthew Butterick | 2 Sep 03:20 2014

How `scribble` resolves relative paths

I am confused by this statement in the docs vs. the actual behavior:

The docs for `image` say that "If path is a relative path, it is relative to the current directory, which is set by `raco setup` and `scribble` to the directory of the main document file." (I'm using `image` as an example but I've seen the same problem with CSS files.)

Suppose I have a project set up like this:

/project
    /scribblings
        main.scrbl
        sample.gif

And "main.scrbl" contains this:

#lang scribble/manual
<at> image["sample.gif"] 

If I do this:
> cd project
> cd scribblings
> scribble main.html

The HTML will render fine.

But if I do this:

> cd project
> scribble --dest-name doc scribblings/main.scrbl

I'll get this error:

open-input-file: cannot open input file
  path: /project/sample.gif

Thus, the relative path "sample.gif" is being resolved relative to the directory where I invoke the `scribble` command, not the "directory of the main document file", which in both cases seems like it should be  /project/scribblings (i.e., the directory containing "main.scrbl").

What am I misunderstanding?






____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Dmitry Pavlov | 1 Sep 17:12 2014
Picon

fl vs. unsafe-fl

Hello,

I was wondering whether operations with flonums and flvectors work
slower than their unsafe- counterparts in intensive numerical tasks.

Here is an example: res = a+b*c

#lang racket

(require racket/flonum
          racket/unsafe/ops)

(define n 1000)
(define k 100000)

(define a (make-flvector n 1.0))
(define b (make-flvector n 2.0))
(define c (make-flvector n 3.0))
(define res (make-flvector n))

(define (test-perf)
   (for ((i (in-range k)))
     (for ((j (in-range n)))
       (flvector-set!
        res j (fl+ (flvector-ref a j)
                   (fl* (flvector-ref b j)
                        (flvector-ref c j)))))))

(define (test-perf-unsafe-ops)
   (for ((i (in-range k)))
     (for ((j (in-range n)))
       (flvector-set!
        res j (unsafe-fl+ (flvector-ref a j)
                          (unsafe-fl* (flvector-ref b j)
                                      (flvector-ref c j)))))))

(define (test-perf-unsafe-flvec)
   (for ((i (in-range k)))
     (for ((j (in-range n)))
       (unsafe-flvector-set!
        res j (fl+ (unsafe-flvector-ref a j)
                   (fl* (unsafe-flvector-ref b j)
                        (unsafe-flvector-ref c j)))))))

(define (test-perf-unsafe-all)
   (for ((i (in-range k)))
     (for ((j (in-range n)))
       (unsafe-flvector-set!
        res j (unsafe-fl+ (unsafe-flvector-ref a j)
                          (unsafe-fl* (unsafe-flvector-ref b j)
                                      (unsafe-flvector-ref c j)))))))

(time (test-perf))
(time (test-perf-unsafe-ops))
(time (test-perf-unsafe-flvec))
(time (test-perf-unsafe-all))

Result (Racket 6.1.0.2, Linux 64-bit):

cpu time: 1704 real time: 1704 gc time: 0
cpu time: 1692 real time: 1692 gc time: 0
cpu time: 736 real time: 738 gc time: 0
cpu time: 684 real time: 682 gc time: 0

It turns out that replacing arithmetical operations
on flonums with their unsafe- counterparts makes no difference,
unless flvector access is unsafe- too; and even then, making
flvector access unsafe makes a huge improvement, while acceleration
from unsafe ops is about 7%.

I can imagine that the Racket's JIT skips checking the types of
arguments of fl+ and fl* because it figures that since they come
from flvectors, they must be flonums. Am I correct?

If I am correct, then are unsafe-fl arithmetical operations important
at all? Because in numerical programs, nearly every flonum is either
a constant, or a value taken from flvector, or a function argument
that can be traced to the same.

Regards,

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

Dmitry Pavlov | 31 Aug 00:54 2014
Picon

performance of iteration through a vector

Hello,

Consider the following program:

(define n 100)
(define vec (for/vector ((i (in-range n))) i))

(let ((t (current-inexact-milliseconds))
      (sum 0))
  (for ((j (in-range 1000000)))
    (for ((i (in-range n)))
      (set! sum (+ sum (vector-ref vec i)))))
  (displayln (/ (- (current-inexact-milliseconds) t) 1000.0)))
  
(let ((t (current-inexact-milliseconds))
      (sum 0))
  (for ((j (in-range 1000000)))
    (for ((v vec))
      (set! sum (+ sum v))))
  (displayln (/ (- (current-inexact-milliseconds) t) 1000.0)))


On my system (64-bit linux, Racket 6.1.0.2), it gives the following result:

1.016682861328125
6.3261611328125


So we can make a conclusion that (for ((v vec)) ...) is
6x slower than (for ((i (in-range n))) ... (vector-ref vec i) ...)
Is it normal? Would you advise to use the explicit (vector-ref)
when performance matters?

Best regards

Dmitry

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
George Neuner | 26 Aug 03:42 2014
Picon
Picon

Package installation VERY SLOW


Hi all,

I'm running Racket under 64-bit Win7 Home on an i7 with 12GB of RAM.

Just upgraded to 6.0.1 from 5.3.4.  I know it's a big leap and 6.1 is
out already, but I tried 6.1 and quickly experienced several of those
non-reproducible crashes I've been reading about in the lists.

6.0.1 is behaving itself, but installing new packages from PLaneT or
migrating packages from the older version is taking HOURS ...
virtually all of it spent processing .scrbl files.

I have both 32 and 64 bit versions: doesn't matter which version I
use, how much memory I give to Racket (in racket-prefs.rktd), or
whether I use raco from the command line or the GUI-based package
manager.

Example: trying to install *just* Neil's CSV:2:0 took nearly an hour
(yes, it has several dependencies).  With 64-bit Racket configured for
3GB, memory use spiked over 1.9GB according to Process Explorer.  And
that was the *fastest* installation ... reducing the memory limit
below 2GB just slows it down.
[I didn't try running the 32-bit version with more than 1.5GB, but it
behaved the same way ... reducing the memory limit just slowed it
down.]

For giggles I tried migrating CSV:1:7 (which has a single dependency
not shared with 2:0) from 5.3.4.  That still took almost 16 minutes,
and again nearly all of it processing some .scrbl file.  For more
giggles, I nuked the PLaneT cache so as to start over: same 16 minutes
for fresh install of 1:7.

For comparison, 5.3.4 installs CSV:1:7 fresh in under 3 minutes.

???  Is anyone else running 6.x on Windows?  I can't figure out what,
if anything, I'm doing wrong.

Subjectively, 6.0.1 feels sluggish compared to 5.3.4 (with same memory
limits), but I haven't gotten to the point where I can objectively
test much because a lot of my programs depend on external packages.
Based on the few I have tried to install/migrate so far, Halloween may
be past before I am able to do any real work with 6.0.1.

George

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

Daniel Bastos | 29 Aug 16:27 2014

missing solution 19.1.6 ex:abs-sort

A candidate for a solution.

;; sort1 : list-of-numbers  ->  list-of-numbers
;; to construct a list with all items from alon in descending order
(define (sort1 cmp alon)
  (local ((define (sort alon)
            (cond
              [(empty? alon) empty]
              [else (insert (first alon) (sort (rest alon)))]))
          (define (insert an alon)
            (cond
              [(empty? alon) (list an)]
              [else (cond
                      [(cmp an (first alon)) (cons an alon)]
                      [else (cons (first alon) (insert an (rest alon)))])])))
    (sort alon)))

(check-expect (sort1 < (list 2 3 1 5 4)) (list 1 2 3 4 5))
(check-expect (sort1 > (list 2 3 1 5 4)) (list 5 4 3 2 1))

Source: 

No Solution Written, yet

Unfortunately, the solution to this exercise has not yet been written. To submit a solution you have written to this problem, or to complain that the solution isn't available, please contact Robby Findler.

To see the list of solutions, visit the table of contents. Each of the hyperlinked exercise numbers has a solution.

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
John Clements | 28 Aug 19:59 2014

Share a room at RacketCon / Strange Loop?

It looks like I’m going to RacketCon & Strange Loop, lucky me. Anyone want to share a room?

John

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

Enrique Comer | 27 Aug 20:42 2014

[->] How to render math formulas with LaTeX under Scribble [solved]

Hi Jens Axel:

Really thank you very much.

It work exactly as you said.
Now I applied racket-poppler under scribble/manual with the following code, as a test:

#lang scribble/manual
<at> (require racket-poppler/render-tex pict)
<at> (latex-path 
 (case (system-type)
   [(macosx) "/usr/local/texlive/2013/bin/universal-darwin/pdflatex"]
   [(unix)   "pdflatex"] 
   [(windows) "c:/Archivos de programa/MiKTeX 2.9/miktex/bin/pdflatex.exe"])) ; personalized
<at> title{Beautiful: <at> (latex->pict "$e^{i \\pi}=-1$") }
Now we have just to learn how to scale the equation <at> (latex->pict "$e^{i \\pi}=-1$") to the right font size. Thank you very much Jens Axel Soegaard.

And worked just fine.

Thank you again for all your support, and by the way, congratulations for your number theory and linear algebra functions at the math library.

Sincerely, Enrique

P.S. It would be of great value, to be able to add latex functions to the plot library. Thanks.

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

Gmane