Kevin Forchione | 29 Nov 01:17 2014

cKanren question

Why does cKanren return ‘() instead of ‘(#f), which is what The Reasoned Schemer seems to expect, for
the following?

#lang racket

(require cKanren/miniKanren)

#;(run #f (q) fail)
(run #f (q) (== #t q))
#;(run #f (q) fail (== #t q))
#;(run #f (q) succeed (== #t q))
#;(run #f (r) succeed (== 'corn r))
#;(run #f (r) fail (== 'corn r))
(run #f (q) succeed (== #f q))

I get ‘(#t) for (run #f (q) succeed (== #t q)) which is what I’d expect. But running the above program only
returns ‘() when unifying q with #f. 


  Racket Users list:
Animesh Pandey | 28 Nov 22:41 2014

How to iterate through the arrays in a matrix?

I have a 80 X 4 matrix. I have iterate through each row and subtract each row with another array at each iteration. At first I thought to convert all array to list and do all the operations and then again convert the final list if lists to a matrix. But I somehow think that is not a suited way. I tried using "for*/matrix" but could not get it right. Could any one give an example on how to iterate a matrix (array for arrays)?

My matrix looks like this:
> (list*->matrix final-data)
 #[#[5.1 3.5 1.4 0.2]
   #[4.9 3.0 1.4 0.2]
   #[4.7 3.2 1.3 0.2]
   #[4.6 3.1 1.5 0.2]
   #[5.0 3.6 1.4 0.2]
   #[5.4 3.9 1.7 0.4]
   #[4.6 3.4 1.4 0.3]
   #[5.0 3.4 1.5 0.2]
   #[4.4 2.9 1.4 0.2]
   #[4.9 3.1 1.5 0.1]

  Racket Users list:
Animesh Pandey | 28 Nov 17:51 2014

How to convert a list of lists to a matrix?

I read a csv file and converted 150 rows and 4 columns to a list of 150 lists. I want to convert this list to a matrix of 150 X 4 dimensions. 
Should I be using "build-matix" or "make-matrix"?
  Racket Users list:
Jens Axel Søgaard | 28 Nov 15:55 2014

Re: Syntax objects in prefab structures

2014-11-28 15:45 GMT+01:00 Matthew Flatt <mflatt@...>:
> Prefab structures are tested like pairs, vectors, and boxes in syntax
> objects. For example, `datum->syntax` and `syntax->datum` can recur
> into a prefab, but they don't go into transparent structures.
> If you add a list to your list of two structures,
>  (set! structs (list (list #'foox) (foo #'foox) (bar #'barx)))
> then you'll see that the prefab's content is treated the same way as
> the list content.

I guess I need to stop thinking of prefab structures as (just)
non-generative structs.

/Jens Axel
  Racket Users list:

Jens Axel Søgaard | 28 Nov 15:38 2014

Syntax objects in prefab structures

The following program shows a difference between syntax objects stored
in prefab structures versus
transparent structures.

Is this a bug - or am I missing something about prefab structures?

#lang racket
  (struct foo (baz) #:prefab)
  (struct bar (baz) #:transparent)
  (define structs '()))

(define-syntax (macro1 stx)
  (set! structs (list (foo #'foox) (bar #'barx)))

(begin-for-syntax (displayln (list 1 structs)))
(begin-for-syntax (displayln (list 2 structs)))

(define-syntax (with stx)
  (with-syntax ([s structs])
          (set! structs 's))


(begin-for-syntax (displayln (list 3 structs)))

The output is:

Welcome to DrRacket, version [3m].
Language: racket; memory limit: 256 MB.
(1 ())
(2 (#s(foo .#<syntax:8:29 foox>) #(struct:bar .#<syntax:8:42 barx>)))
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))
(1 ())
(2 ())
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))
(1 ())
(2 ())
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))

The syntax object in the prefab structure turned into a symbol !

Jens Axel Søgaard

  Racket Users list:
Catonano | 26 Nov 11:37 2014

SICP (again)


I understand that this is not the first time someone asks about using Racket for a SICP study group.

I used the not so mantained mit-scheme compatibility package and I tried to paste this piece of code

(define (average x y)
    (/ (+ x y) 2))
(define (sqrt x)
    (define (improve guess)
        (average guess (/ x guess )))
    (define (good-enough? guess)
        (< (abs (- (square guess) x )) .001))
    (define (try guess)
        (if (good-enough? guess)
            (try (improve guess))))
        (try 1))

It should be the Newton's method to calculate the square root

We copied it from the lectures

In this code we use the "square" function. In mit-scheme it's ok, in Racket it's not defined

Should I import any module ?

Are common functions named as in mit-scheme ? Or are we gonna run into compatibility issues ?

Thanks for any hint
  Racket Users list:
Chrakhan Barzanji | 25 Nov 11:29 2014

jQuery.console or Racket code?

 could some body tell me if TryRacket-Online uses only the jquery-console implementation to evaluate the inputs or calls somehow the RacketCode (main.rkt & co.)
  Racket Users list:
Jacob Mitchell | 25 Nov 05:51 2014

Scribble: requiring an LP from another LP

I'm new to Scribble and I'm running into some problems splitting my literate program across multiple files.

The documentation says an rkt file with a "#lang scribble/lp" can be required from another Racket program like any other rkt file. That works fine, but requiring one scribble/lp from another doesn't seem to work. In particular, functions defined in the dependent scribble/lp aren't available to <at> chunks in the referencing scribble/lp, even when they're explicitly exposed via (provide ...).

To clarify, here's an example involving a few files placed in the same directory.

;; FILE: main.scrbl
#lang scribble/base
<at> require[scribble/lp-include]
<at> lp-include["prelude.rkt"]
<at> lp-include["chapter1.rkt"]
;; FILE: prelude.rkt
#lang scribble/lp
<at> chunk[<prelude>
(provide atom?)
(define atom?
  (lambda (x)
    (and (not (pair? x)) (not (null? x)))))]

;; FILE: chapter1.rkt (fails to access the Prelude's definition of "atom?")
#lang scribble/lp
<at> require["prelude.rkt"]
<at> chunk[<atom?-test>
(define atom-test (atom? 1))]

;; FILE: prelude-lib-test.rkt (successfully accesses "atom?")
#lang racket
(require "prelude.rkt")
(define atom-test (atom? 1))

In prelude-lib-test.rkt atom-test evaluates to #t as expected. However, when I try to evaluate atom-test from chapter1.rkt I'm met with this error:

atom-test: undefined;
 cannot reference an identifier before its definition

Is there something else I should try, or is requiring LPs from LPs like this not currently supported?

  Racket Users list:
Daniel Feltey | 24 Nov 21:59 2014

language-info in #lang typed/racket files vs. (module _ typed/racket ...) files

I'm trying to use `module->language-info` to determine if a module I am requiring is written in
typed/racket or racket, since if the module is implemented in racket `module->language-info` will
return #f, but a vector if the module was typed. 

The problem I'm running into is that with files of the form:

;; foo.rkt
(module foo typed/racket

(module->language-info "foo.rkt" #t) returns #f even though I expect a language-info that tells me the
file is written in typed/racket.

Changing foo.rkt to the following:

;; foo.rkt
#lang typed/racket

Then gives a non-false language-info vector when calling (module->language-info "foo.rkt" #t).

Is this the expected behavior? I thought that the #lang version of the file should be equivalent to the
(module ...) version.

This seems to be addressed somewhat in but it doesn't explain why (module
...) doesn't get language-info.

  Racket Users list:

Eli Barzilay | 24 Nov 20:51 2014

Vote for PLAI

A few minutes after my edit the editor started the discussion & votes.
See it here:

And please vote to keep the page.  To do that, hit the edit button and
add something like "* '''Keep''' blah blah blah".  (Using three single
quotes for bold.)


          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                             Maze is Life!
  Racket Users list:

Eli Barzilay | 24 Nov 18:45 2014

PLAI WP page scheduled to be deleted

I happened to notice this yesterday:

Which means that if nothing id done, it gets deleted in two days.  Last
time it happened (with the Racket page), there was also a discussion on
the talk page, and this time there is nothing.  Even worse, the proposed
deltion has a template to let the page author or project know about it,
and I don't think that it was used (though I'm not the author of that

IIUC, one possible thing to do is to just remove the proposition, and
justify that in the talk page or in the commit message.  The next step
would be that this will move to a discussion place where there will be a
vote.  But it's probably best if the page itself is improved.  So this
is a call for people to do that -- especially if you have some WP
writing experience and know how to deal with these situations.


          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                             Maze is Life!
  Racket Users list: