[racket-users] racket virtual machine

2015-06-03 Thread Neil Van Dyke
How hard is it to implement the Racket virtual machine (no JIT) for a 
single target architecture one knows?


Say, is this a one-weekend task, or a one-month task?

Neil V.

--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket virtual machine

2015-06-03 Thread Jens Axel Søgaard
Depends. If you count all the primitives - then one-month won't be enough.

The actual operations of the virtual machine are certainly doable in a
reasonable amount of time.

A Racket VM written in Racket:

https://github.com/soegaard/meta/blob/master/runtime/racket-eval.rkt

(submodules not supported yet, but it is a relatively small change).

/Jens Axel


2015-06-04 0:59 GMT+02:00 Neil Van Dyke n...@neilvandyke.org:

 How hard is it to implement the Racket virtual machine (no JIT) for a
 single target architecture one knows?

 Say, is this a one-weekend task, or a one-month task?

 Neil V.

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread Prabhakar Ragde
This is a homework question of mine (though I don't think the OP is 
doing homework for a course for credit; I'd be curious to know where he 
found it). I usually state the restrictions on 'reverse' and 'remove', 
but not 'member?'. The restriction on 'reverse' is so that students 
don't write one of the functions by reversing, calling the other, 
reversing again. Also sometimes when students violate structural 
recursion, they get a reversed result, and I don't want them applying 
'reverse' as a quick fix. The restriction on 'remove' is on the built-in 
function of that name, because it only removes one element, and using it 
leads students away from structural recursion. Recently I have taken to 
hinting that they should write something like remove*. --PR


--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] terminal emulator

2015-06-03 Thread William G Hatch


Hello racketeers,

I'm pretty new to racket, so to get some experience with it I've been
writing a terminal emulator.  It's coming along nicely (it is one
control code away from being able to nicely run vim), and is at
https://github.com/willghatch/rackterm for your browsing pleasure.  I
have run into some difficulties that I would like some advice for:

Its main problem currently is that it spends a lot of time drawing.  I
am using a canvas% and I override its dc%'s on-paint to get the contents
and then draw them on screen.  I call the refresh method to queue a
re-paint whenever I get new input.  If I, say, start up vim and start
writing in it, my input lags behind as it spends all its time
repainting.  Are there some good practices for drawing stuff quickly?

I was also wondering, before I start searching and grepping all over, if
someone who knows can point me to where I can see how drracket formats
the contents of its text panes (IE adds color, etc).  Whatever it's
doing seems to be good, so perhaps I can leverage something there.

My other biggest issue right now is getting the child processes to
register window size changes, and I'm not sure whether it's a problem
with how I'm setting things up with the child or with how I'm sending
the resize signals through the parent.  It's all through FFI calls into
the black box of ioctl, so it has nothing to do with racket, but if any
of you have tips for that, I would also appreciate it.  But related to
that, I have some C constants hard coded right now in racket for the
FFI.  Is there a way for me to get them out of the C header file so it
won't just break if/when the header changes?

Thanks in advance,

William Hatch

--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket virtual machine

2015-06-03 Thread Raoul Duke
Evil question: Has anybody ever looked at how the bytecode could be
interpreted on another VM e.g. JVM?

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Parallelism / atomic?

2015-06-03 Thread Robby Findler
Racket threads are not cooperative multitasking. There are no explicit
yield points. The runtime system still schedules the threads
independently, but there is only ever at most one running at a time.
Racket's threads are designed to support concurrency (ie a particular
kind of non-determinism useful for networking and guis etc), not
parallelism.

Threads support sequential consistency, and mutations via set! are atomic.

The support for parallelism in Racket includes places (a
message-passing mechanism with no shared memory) and futures (shared
memory).

In both cases of these cases, there is little that is atomic and the
memory model is crappier than sequential consistency as Racket
currently reflects what the OS and hardware support.

Robby



On Wed, Jun 3, 2015 at 12:36 AM, Michael Tiedtke
michael.tied...@o2online.de wrote:
 I'm currently implementing a new parallel objects policy (SAKE: Skip
 Animation and Skedule) and I'm supposing that setting boolean values (even
 with an accessor via send) is atomic with respect to its reads. I can't
 remember where but the documentation (Guide or Reference) somewhere stated
 that most primitive operations are atomic ... Is there any way to find out
 about the atomicity of procedures / primitives in Racket?  The standards
 currently do not guarantee anything in this respect.

 Some examples with the theoretical predicate atomic?:

 (atomic? semaphore-try-wait?) = #t
 (define my-boolean #f)
 (atomic? {lambda () (set! my-boolean #t)} = #t
 (atomic? {lambda () (if my-boolean 'yes 'no)} = #t
 (atomic? {lambda () [when my-boolean (set! my-boolean #f)]} = #f


 Parallelism in my current project is a result of nested event handling. But
 when it comes to threads I found the following statements about threads in
 the Guide (Parallelism):

  Other functions, such as thread, support the creation of reliably
 concurrent tasks. However, threads never run truly in parallel, even if the
 hardware and operating system support parallelism.

 Is there any good reason for this? It sounds like cooperative multitasking
 ...


 The Racket Foreign Interface describes another type of atomicity: Disables
 and enables context switches and delivery of break exceptions at the level
 of Racket threads. One could even call this virtual atomicity.

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread mazert

Le 03/06/2015 07:25, Paul Bian a écrit :

Hi all,



one function to remove duplicates from the left,

i.e. 1 2 1 3 2 4 5 - 1 2 3 4 5

and one from the right.

i.e. 1 2 1 3 2 4 5 - 1 3 2 4 5


Hello,

For the first function, I think you can't do it without a local define 
or by adding a second parameter (for result). Here is my solution :


(define (right L)
  (cond ((empty? L) (list))
((member? (car L) (cdr L)) (right (cdr L)))
(else (cons (car L) (right (cdr L))

(define (left L res)
  (cond ((empty? L) res)
((not (member? (car L) res)) (left (cdr L) (append res 
(list(car L)

(else (left (cdr L) res


For left, I use an empty list at initialisation (res), and I can check 
if an element have already been added. I didn't use reverse but it is 
recommanded instead of append cause it cost less of computing time.


append = reverse = O(n) . But i use append more than one time.

In practise I never use remove, cause it cost a lot of computing time 
too O(pos) (cause have to reindex each element of the list each time), 
except if you remove the first element, but (cdr) does it ;) .



--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Parallelism / atomic?

2015-06-03 Thread Michael Tiedtke
Thank you! The set! primitive is atomic - that's good.

Futures and Places both are interesting concepts with implementations
and documentation.

But what if I want to try my own model? Let's say, for example, tying true
parallelism to objects (by using environments, a special send and threads
in the usual sense without any further overhead by the runtime
environment if not my own? Racket's model of threads doesn't seem to
grant me that freedom anymore but the GUI toolkit - on the other hand -
already ties threads to top level windows and their event spaces.

Racket is still a programming language where I can redefine define to be
'null but I can't use low level threads as specified in SRFI-18?
(http://srfi.schemers.org/srfi-18/srfi-18.html)

Il giorno 03/giu/2015, alle ore 13.37, Robby Findler ha scritto:

 Racket threads are not cooperative multitasking. There are no explicit
 yield points. The runtime system still schedules the threads
 independently, but there is only ever at most one running at a time.
 Racket's threads are designed to support concurrency (ie a particular
 kind of non-determinism useful for networking and guis etc), not
 parallelism.
 
 Threads support sequential consistency, and mutations via set! are atomic.
 
 The support for parallelism in Racket includes places (a
 message-passing mechanism with no shared memory) and futures (shared
 memory).
 
 In both cases of these cases, there is little that is atomic and the
 memory model is crappier than sequential consistency as Racket
 currently reflects what the OS and hardware support.
 
 Robby
 
 
 
 On Wed, Jun 3, 2015 at 12:36 AM, Michael Tiedtke
 michael.tied...@o2online.de wrote:
 I'm currently implementing a new parallel objects policy (SAKE: Skip
 Animation and Skedule) and I'm supposing that setting boolean values (even
 with an accessor via send) is atomic with respect to its reads. I can't
 remember where but the documentation (Guide or Reference) somewhere stated
 that most primitive operations are atomic ... Is there any way to find out
 about the atomicity of procedures / primitives in Racket?  The standards
 currently do not guarantee anything in this respect.
 
 Some examples with the theoretical predicate atomic?:
 
 (atomic? semaphore-try-wait?) = #t
 (define my-boolean #f)
 (atomic? {lambda () (set! my-boolean #t)} = #t
 (atomic? {lambda () (if my-boolean 'yes 'no)} = #t
 (atomic? {lambda () [when my-boolean (set! my-boolean #f)]} = #f
 
 
 Parallelism in my current project is a result of nested event handling. But
 when it comes to threads I found the following statements about threads in
 the Guide (Parallelism):
 
 Other functions, such as thread, support the creation of reliably
 concurrent tasks. However, threads never run truly in parallel, even if the
 hardware and operating system support parallelism.
 
 Is there any good reason for this? It sounds like cooperative multitasking
 ...
 
 
 The Racket Foreign Interface describes another type of atomicity: Disables
 and enables context switches and delivery of break exceptions at the level
 of Racket threads. One could even call this virtual atomicity.
 
 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
 

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Parallelism / atomic?

2015-06-03 Thread Robby Findler
On Wed, Jun 3, 2015 at 9:18 AM, Michael Tiedtke
michael.tied...@o2online.de wrote:
 Thank you! The set! primitive is atomic - that's good.

Just to be clear: when you are using futures with set!, you get the
lower-level guarantees here, which do not include atomicity, indeed
not even SC.

 Futures and Places both are interesting concepts with implementations
 and documentation.

 But what if I want to try my own model? Let's say, for example, tying true
 parallelism to objects (by using environments, a special send and threads
 in the usual sense without any further overhead by the runtime
 environment if not my own? Racket's model of threads doesn't seem to
 grant me that freedom anymore but the GUI toolkit - on the other hand -
 already ties threads to top level windows and their event spaces.

You would need to build them on top of either places or futures. (Or
tackle the problem of making a new runtime system for Racket, I
suppose. But I guess that's not necessary in this case.)

 Racket is still a programming language where I can redefine define to be
 'null but I can't use low level threads as specified in SRFI-18?
 (http://srfi.schemers.org/srfi-18/srfi-18.html)

Racket is a programming language built by PL enthusiasts/researchers
to do what we were interested in doing and to help us try to solve
problems we wanted to solve. It isn't a finished product and if you
want to build something with it or extend it, you are welcome to join
in.

That said, it isn't the right platform for everyone and there are many
things under the sun.

Best,
Robby

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Removing duplicates from a list while maintaining order

2015-06-03 Thread Matthias Felleisen

In BSL: 

;; -
;; [Listof X] - [Listof X]
;; remove duplicates ...

;; -
;; ... keeping the copy on the left 
(require racket/base) ;; to import remove*, a variant of which should be in *SL

(check-expect (unique-l (list 1 2 1 3 1 2)) (list 1 2 3))

(define (unique-l l)
  (cond
[(empty? l) '()]
[else (cons (first l) (remove* (list (first l)) (unique-l (rest l]))

;; -
;; ... keeping the copy on the right
(check-expect (unique-r (list 1 2 1 3 1 2)) (list 3 1 2))

(define (unique-r l)
  (cond
[(empty? l) '()]
[else (if (member? (first l) (rest l))
  (unique-r (rest l))
  (cons (first l) (unique-r (rest l]))



On Jun 3, 2015, at 1:25 AM, Paul Bian paulb...@gmail.com wrote:

 Hi all,
 
 Trying to learn a bit about recursion in racket.
 The question is to remove duplicates from a list while maintaining the order 
 of the list.
 
 one function to remove duplicates from the left, 
 
 i.e. 1 2 1 3 2 4 5 - 1 2 3 4 5
 
 and one from the right.
 
 i.e. 1 2 1 3 2 4 5 - 1 3 2 4 5
 
 I've gotten the code to work by writing some helper functions, but my 
 question is, is it possible to solve these problems WITHOUT:
 
 - local definition (i.e. beginner student language in dr racket)
 - loops
 - built in 'remove', 'reverse', 'member?'
 - writing your own 'remove', 'reverse', 'member?' functions
 
 OR if 'member?' is allowed... I can figure out the right side case without 
 additional functions, but not for the left case, is there a way to do this 
 without the remove duplicates function that i wrote?
 
 ---
 Code:
 
 http://pastebin.com/h0dBdUaR
 
 (define (RemoveElement element lst)
 ;if unique-left is applied to (list 1 4 2 1 5 4), the result would be (list 1 
 4 2 5)
  (cond
[(empty? lst) empty]
[(= element (first lst)) (RemoveElement element (rest lst))]
[else (cons (first lst) (RemoveElement element (rest lst)))]))
 
 (define (unique-left lst)
  (cond
[(empty? lst) empty]
[(member? (first lst) (rest lst)) (cons (first lst) (unique-left 
 (RemoveElement (first lst) (rest lst] 
[else (cons (first lst) (unique-left (rest lst)))]
)
  )
 
 (define (unique-right lst)
 ;the result of applying it to (list 1 4 2 1 5 4) would be (list 2 1 5 4)
  (cond
[(empty? lst) empty]
[(not (member? (first lst) (rest lst))) (cons (first lst) (unique-right 
 (rest lst)))]
[else (unique-right (rest lst))]))
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread Paul Bian
Thanks for all the help guys, it really helps with my understanding. 

So it seems to me there's no real easy way to do this while keeping all the 
restrictions intact. 

I sat here thinking about it for quite a while before posting, as I thought I 
missed some simple solution, as I'm inexperienced.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Strange behavior when writing to a file

2015-06-03 Thread Mark Lee
On Tuesday, June 02, 2015 04:47:33 PM Matthew Flatt wrote:
 I think you wanted `(and (=` in place of `(or (`.

That did it, thanks a lot!
Mistake on my part when I wrote it, the string-length check was added 
afterwords so I used an or statement instead of an and.

Regards,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: This is a digitally signed message part.


[racket-users] racket/gui : How to do not get n elements in the desktop taskbar when opening n frame%

2015-06-03 Thread mazert

Hello,

When I open multi frame% objects, I automaticaly have multi elements on 
my desktop taskbar, but I want to have only one element. How I can proceed ?


Thanks in advance.


--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread Matthias Felleisen

Apologies for posting a solution. Since the OP had some code, I thought I'd 
show him the essence .. throwing in (require racket) as the key to any 
instructor who'd grade (and care that a student had cheated). 

-- Matthias





On Jun 3, 2015, at 8:07 PM, Prabhakar Ragde wrote:

 This is a homework question of mine (though I don't think the OP is doing 
 homework for a course for credit; I'd be curious to know where he found it). 
 I usually state the restrictions on 'reverse' and 'remove', but not 
 'member?'. The restriction on 'reverse' is so that students don't write one 
 of the functions by reversing, calling the other, reversing again. Also 
 sometimes when students violate structural recursion, they get a reversed 
 result, and I don't want them applying 'reverse' as a quick fix. The 
 restriction on 'remove' is on the built-in function of that name, because it 
 only removes one element, and using it leads students away from structural 
 recursion. Recently I have taken to hinting that they should write something 
 like remove*. --PR
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread Michael Tiedtke
Il giorno 03/giu/2015, alle ore 17.04, Paul Bian ha scritto:

 Thanks for all the help guys, it really helps with my understanding. 
 
 So it seems to me there's no real easy way to do this while keeping all the 
 restrictions intact. 
 
 I sat here thinking about it for quite a while before posting, as I thought I 
 missed some simple solution, as I'm inexperienced.
 



While developing with theoretical restrictions is good for practicing in 
practice I suggest to rely on high level list handling routines like sort, 
filter, map and for-each as these usually are optimized.  You might want to 
have a look at different implementations of SRFI 1 delete-duplicates. Or think 
about it in terms of sets with SRFI 113. As the problem is related to sorting 
you might want to have a look at the by now deprecated SRFI 32: its reference 
implementation includes heap sort, quick sort and perhaps others.

See http://docs.racket-lang.org/srfi/srfi-std/srfi-1.html#Deletion

delete-duplicates [=] - list
Be aware that, in general, delete-duplicates runs in time O(n2) for n-element 
lists. Uniquifying long lists can be accomplished in O(n lg n) time by sorting 
the list to bring equal elements together, then using a linear-time algorithm 
to remove equal elements. Alternatively, one can use algorithms based on 
element-marking, with linear-time results.


See http://srfi.schemers.org/srfi-113/srfi-113.html#Copyingandconversion

(list-set comparator list)
Returns a newly allocated set, created as if by set using comparator, that 
contains the elements of list. Duplicate elements (in the sense of the equality 
predicate) are omitted.


http://srfi.schemers.org/srfi-95/srfi-95.html 
(http://srfi.schemers.org/srfi-32/srfi-32.txt)
To choose optimal sort algorithms requires nearly as much understanding as to 
write them. Most users don't.

If you have big data with duplicates you should try to use a directed graph 
instead of well formed lists. It's fast and has a small memory footprint when 
there are many duplicates, i.e. a lot of redundancy in the data. Language 
contains a lot of redundancy (both at the word and at the letter level). This 
direction leads to searching (sth like the whole WWW in O(n)) and compression 
algorithms ...

Have fun,
Michael

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Removing duplicates from a list while maintaining order

2015-06-03 Thread Paul Bian
I'm not a student, and haven't touched scheme since first year university in 
2006. I overheard the problem discussed and wanted to give it a shot. 
Essentially wondering since I couldn't do it with all the constraints, whether 
I'm lacking some fundamental understanding.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket virtual machine

2015-06-03 Thread Robby Findler
Just because no one has mentioned it yet: there is a C implementation
of the VM (and the primitives) so if you have a C compiler and an OS
for that architecture, it shouldn't be too hard.

Robby

On Wed, Jun 3, 2015 at 5:59 PM, Neil Van Dyke n...@neilvandyke.org wrote:
 How hard is it to implement the Racket virtual machine (no JIT) for a single
 target architecture one knows?

 Say, is this a one-weekend task, or a one-month task?

 Neil V.

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.