Re: [racket-users] Recursevly processing a list with "wholes"

2016-11-16 Thread Meino . Cramer
Hi Justin,

thanks for reply and the code! :)

Cheers
Meino


Justin Zamora  [16-11-17 04:02]:
> I think you are looking for something like this:
> 
> #lang racket
> 
> (require test-engine/racket-tests)
> 
> (define (remove-empty-lists lst)
>   (cond
> [(null? lst) '()] ; Check for end of list
> [(null? (first lst)) (remove-empty-lists (rest lst))] ; Skip null
> sublist
> [(not (list? (first lst))) ; Leave non-lists alone
>  (cons (first lst) (remove-empty-lists (rest lst)))]
> [else ; Process the sublists recursively
>  (cons (remove-empty-lists (first lst))
>(remove-empty-lists (rest lst)))]))
> 
> (check-expect (remove-empty-lists '()) '())
> (check-expect (remove-empty-lists '(a)) '(a))
> (check-expect (remove-empty-lists '(a b c)) '(a b c))
> (check-expect (remove-empty-lists '(())) '())
> (check-expect (remove-empty-lists '(() a)) '(a))
> (check-expect (remove-empty-lists '(a ())) '(a))
> (check-expect (remove-empty-lists '(a (b () c) d)) '(a (b c) d))
> (check-expect (remove-empty-lists '((a) (b c) () (e () f (g ())) h (() i
> j)))
>   '((a) (b c) (e f (g)) h (i j)))
> (test)
> 
> Justin
> 
> On Tue, Nov 15, 2016 at 10:52 PM,  wrote:
> 
> > Hi,
> >
> > I have a list of sublists. Some of the sublists are empty.
> > The list should be processed recursevly and the resulting
> > list should no longer contain empty sublists.
> >
> > The code I have so far looks like:
> >
> > (define (step-through-list lst)
> > (if (empty? lst)
> > lst
> > (cons (process-sublist (car lst)) (step-through-list (cdr lst)))
> >
> > but "car" would feed empty sublists to process-sublist as any other
> > sublist. How can I "silently" skip empty sublists and even get out of
> > the recursion without harm (if the last sublist is empty) without
> > switching to iteration?
> > Is there something like "car-not-empty" ? ;)
> > Or do I oversee the obvious here...? ;)))
> >
> > Thank you vary much for any help in advance!
> > Cheers
> > Meino
> >
> >
> > --
> > 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.

-- 
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] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper

On 11/16/2016 08:24 PM, Dan Liebgold wrote:

FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro
that is used extensively inside TR.


https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt



Hmm... I can't quite figure that one out. Maybe with some examples?
How does the ":spec" in the pattern work?  It's just a class
specified


Suppose you have

  (define-syntax-class sc #:attributes (a b) )

The pattern x:sc or (~var x sc) binds x, x.a, and x.b.
The pattern :sc or (~var || sc) binds just a and b (no prefix).
The pattern _:sc or (~var _ sc) binds nothing.

Note that || is a way of writing the 0-length identifier in Racket.

Ryan

--
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] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper

On 11/16/2016 07:51 PM, Vincent St-Amour wrote:

FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro
that is used extensively inside TR.


https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt

Its companion `define-merged-syntax-class` is quite nice too.


https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/optimizer/utils.rkt#L110

I've used those in other projects as well, and like them a lot.

Ryan: Would you consider adding them (or something like them) to
syntax/parse?


I could add a `#:define-syntax-class name` option to 
`define-literal-set` that would additionally define `name` as a 
syntax-class matching any of the literals. I would want to wait to add 
that until I implement the backtracking-aware handling of 
disappeared-uses, which I just haven't gotten to yet.


For `define-merged-syntax-class`, I don't think I would put it in core 
syntax/parse, but maybe as a library in syntax/parse/lib/*.


Ryan

--
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] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper

On 11/16/2016 07:42 PM, Dan Liebgold wrote:


Literal sets can include datum-literals:

(define-literal-set lits #:datum-literals (a b c) (d e))



Ah, oops I missed that keyword parameter.


For question 1, that's probably the best way. If you want to suppress
the printing of all of the datum literals in error messages, you can
mark the syntax class as `#:opaque`.



I was more wanting to avoid keeping two lists of the literals in the
source... I *do* want the error to enumerate possibilities.


In principle, you could also use `literal-set->predicate`, but I just
discovered it ignores the datum literals. I'll push a fix.



I saw that... assuming it worked, I'm not sure how/where I would put that..


Something like this:

  (define-literal-set var-type-lits )

  (define-syntax-class var-type
(pattern x:id
 #:fail-unless
   ((literal-set->predicate var-type-lits) #'x)
   "unrecognized var-type"))

But then you wouldn't get the enumeration of the literals in errors either.

Ryan

--
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] If a thunk is a proc of zero arguments, what is a proc of one argument?

2016-11-16 Thread David Storrs
Ah, I should have thought of that.  Yep, it works.  Thanks.

On Wed, Nov 16, 2016 at 5:12 PM, Greg Hendershott  wrote:

> racket-mode is on MELPA:
>
>   https://melpa.org/#/racket-mode
>
> But not MELPA stable.
>
> Personally I use only MELPA non-stable, because I like packages to
> break all the time. Seriously, it's been fine, for me.
>
> In Emacs 24.4+ I understand it's possible to use both. You can say to
> get certain packages from one or the other, using
> `package-pinned-packages`, as explained here:
>
>   http://stackoverflow.com/questions/38632453/how-should-
> i-work-with-melpa-and-melpa-stable-using-emacs/38648126
>
> Also even in older Emacs as explained here under "Customizations":
>
>   https://melpa.org/#/getting-started
>

-- 
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] Recursevly processing a list with "wholes"

2016-11-16 Thread Justin Zamora
I think you are looking for something like this:

#lang racket

(require test-engine/racket-tests)

(define (remove-empty-lists lst)
  (cond
[(null? lst) '()] ; Check for end of list
[(null? (first lst)) (remove-empty-lists (rest lst))] ; Skip null
sublist
[(not (list? (first lst))) ; Leave non-lists alone
 (cons (first lst) (remove-empty-lists (rest lst)))]
[else ; Process the sublists recursively
 (cons (remove-empty-lists (first lst))
   (remove-empty-lists (rest lst)))]))

(check-expect (remove-empty-lists '()) '())
(check-expect (remove-empty-lists '(a)) '(a))
(check-expect (remove-empty-lists '(a b c)) '(a b c))
(check-expect (remove-empty-lists '(())) '())
(check-expect (remove-empty-lists '(() a)) '(a))
(check-expect (remove-empty-lists '(a ())) '(a))
(check-expect (remove-empty-lists '(a (b () c) d)) '(a (b c) d))
(check-expect (remove-empty-lists '((a) (b c) () (e () f (g ())) h (() i
j)))
  '((a) (b c) (e f (g)) h (i j)))
(test)

Justin

On Tue, Nov 15, 2016 at 10:52 PM,  wrote:

> Hi,
>
> I have a list of sublists. Some of the sublists are empty.
> The list should be processed recursevly and the resulting
> list should no longer contain empty sublists.
>
> The code I have so far looks like:
>
> (define (step-through-list lst)
> (if (empty? lst)
> lst
> (cons (process-sublist (car lst)) (step-through-list (cdr lst)))
>
> but "car" would feed empty sublists to process-sublist as any other
> sublist. How can I "silently" skip empty sublists and even get out of
> the recursion without harm (if the last sublist is empty) without
> switching to iteration?
> Is there something like "car-not-empty" ? ;)
> Or do I oversee the obvious here...? ;)))
>
> Thank you vary much for any help in advance!
> Cheers
> Meino
>
>
> --
> 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] syntax-class composed of literals

2016-11-16 Thread Dan Liebgold
> FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro
> that is used extensively inside TR.
> 
>
> https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt
> 

Hmm... I can't quite figure that one out. Maybe with some examples?  How does 
the ":spec" in the pattern work?  It's just a class specified

The examples in TR seem to declare classes one literal at a time?

> Its companion `define-merged-syntax-class` is quite nice too.
> 
>
> https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/optimizer/utils.rkt#L110
> 

I was just looking for exactly that... very useful.

-- 
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] If a thunk is a proc of zero arguments, what is a proc of one argument?

2016-11-16 Thread Greg Hendershott
racket-mode is on MELPA:

  https://melpa.org/#/racket-mode

But not MELPA stable.

Personally I use only MELPA non-stable, because I like packages to
break all the time. Seriously, it's been fine, for me.

In Emacs 24.4+ I understand it's possible to use both. You can say to
get certain packages from one or the other, using
`package-pinned-packages`, as explained here:

  
http://stackoverflow.com/questions/38632453/how-should-i-work-with-melpa-and-melpa-stable-using-emacs/38648126

Also even in older Emacs as explained here under "Customizations":

  https://melpa.org/#/getting-started

-- 
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] syntax-class composed of literals

2016-11-16 Thread Vincent St-Amour
FWIW, Eric Dobson wrote a very nice `define-literal-syntax-class` macro
that is used extensively inside TR.

   
https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/utils/literal-syntax-class.rkt

Its companion `define-merged-syntax-class` is quite nice too.

   
https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/optimizer/utils.rkt#L110

I've used those in other projects as well, and like them a lot.

Ryan: Would you consider adding them (or something like them) to
syntax/parse?

Vincent



On Wed, 16 Nov 2016 17:11:26 -0600,
Dan Liebgold wrote:
> 
> Hi,
> 
> A couple questions about literals in syntax-parse:
> 
> 1. I'd like to make a syntax-class that is just a set of literals (with a 
> clear error for something not matching any literal). Is there a better way 
> than this:
> 
> http://pasterack.org/pastes/86722
> 
> I need to ignore the bindings for those identifiers, and I need to preserve 
> the syntax context.
> 
> 2. Is there any plan or easy way to implement #:datum-literal-sets  for 
> syntax-classes?  It'd be nice to share a list of literals (with ignored 
> bindings) among multiple classes.
> 
> Thanks,
> Dan
> 
> -- 
> 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] syntax-class composed of literals

2016-11-16 Thread Dan Liebgold
> 
> Literal sets can include datum-literals:
> 
>(define-literal-set lits #:datum-literals (a b c) (d e))
> 

Ah, oops I missed that keyword parameter.

> For question 1, that's probably the best way. If you want to suppress 
> the printing of all of the datum literals in error messages, you can 
> mark the syntax class as `#:opaque`.
> 

I was more wanting to avoid keeping two lists of the literals in the source... 
I *do* want the error to enumerate possibilities.

> In principle, you could also use `literal-set->predicate`, but I just 
> discovered it ignores the datum literals. I'll push a fix.
> 

I saw that... assuming it worked, I'm not sure how/where I would put that..

-- 
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] syntax-class composed of literals

2016-11-16 Thread Ryan Culpepper

On 11/16/2016 06:11 PM, Dan Liebgold wrote:

Hi,

A couple questions about literals in syntax-parse:

1. I'd like to make a syntax-class that is just a set of literals
(with a clear error for something not matching any literal). Is there
a better way than this:

http://pasterack.org/pastes/86722

I need to ignore the bindings for those identifiers, and I need to
preserve the syntax context.

2. Is there any plan or easy way to implement #:datum-literal-sets
for syntax-classes?  It'd be nice to share a list of literals (with
ignored bindings) among multiple classes.


Literal sets can include datum-literals:

  (define-literal-set lits #:datum-literals (a b c) (d e))

For question 1, that's probably the best way. If you want to suppress 
the printing of all of the datum literals in error messages, you can 
mark the syntax class as `#:opaque`.


In principle, you could also use `literal-set->predicate`, but I just 
discovered it ignores the datum literals. I'll push a fix.


Ryan

--
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] syntax-class composed of literals

2016-11-16 Thread Dan Liebgold
Hi,

A couple questions about literals in syntax-parse:

1. I'd like to make a syntax-class that is just a set of literals (with a clear 
error for something not matching any literal). Is there a better way than this:

http://pasterack.org/pastes/86722

I need to ignore the bindings for those identifiers, and I need to preserve the 
syntax context.

2. Is there any plan or easy way to implement #:datum-literal-sets  for 
syntax-classes?  It'd be nice to share a list of literals (with ignored 
bindings) among multiple classes.

Thanks,
Dan

-- 
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] Recursevly processing a list with "wholes"

2016-11-16 Thread Meino . Cramer
Hi David,

thanks for the reply and the link! :)

I have a list of sublist, which I want to process recursively.
Some sublists are empty, some are filled.
The typical pattern is (as far as I know)

(define (process-list lst)
(cons (do-somthing-with-sublist (car lst)) (process-lst (car lst

But this has the drawback, that empty sublists (via 'car lst') are
processed also. So I need a "kind of car" which returns not the next
sublist but the next not-empty sublist and skipping any empty sublist
without breaking the recursion.

Others on the list already posted some solutions for what I try to 
acchieve and this is only to clearify things.
Is it now understandable, what I try to acchieve?

Cheers
Meino





David Storrs  [16-11-16 20:16]:
> Hi Meino,
> 
> As a suggestions, you might want to read through this page on Stack
> Overflow about how to ask technical questions:
> http://stackoverflow.com/help/how-to-ask   The summary is:  tell us what
> you're trying to achieve, what you've tried, and what *specifically* is not
> working.
> 
> The question you're asking here (about walk-lists) is hard to help with,
> because it's not clear what the context is.  I'll take my best shot, though:
> 
> On Wed, Nov 16, 2016 at 10:04 AM,  wrote:
> 
> > Hi John,
> >
> > thank you for your reply ! :)
> >
> > ...no, not a homework...
> > I want to teach myself some racket and hope 'to get it' finally...
> > Since I am no native speaker I have the deficulty to search for
> > things, which names I dont know...
> >
> > One example of my code is:
> >
> > (define (trim-list lst)
> >   (if (empty? lst)
> > lst
> > (cons (string-trim (car lst)) (trim-list (cdr lst)
> >
> >
> > (define (walk-sublists lst)
> >   (if (empty? lst)
> > lst
> > (cons (trim-list (car lst)) (walk-sublists (cdr lst)
> >
> > I want to avoid to call trim-list, if 'car lst' returns an empty list.
> > Instead 'car lst' sghould return the next non-empty list...
> >
> > I will take a look in the reference manual for 'filter' and 'compose'.
> >
> > Cheers
> > Meino
> >
> >
> >
> You might try something like this:
> 
> (define (trim-list lst)
>   (if (empty? lst)
> lst
> (cons (string-trim (car lst))
> (trim-list (cdr lst)
> >
> >
> >
> >
> > 'John Clements' via Racket Users 
> > [16-11-16 18:26]:
> > >
> > > > On Nov 15, 2016, at 19:52, meino.cra...@gmx.de wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have a list of sublists. Some of the sublists are empty.
> > > > The list should be processed recursevly and the resulting
> > > > list should no longer contain empty sublists.
> > >
> > > Is this homework?
> > >
> > > if so: can you show your test cases?
> > >
> > > if not: (filter (compose not null?) l).
> > >
> > >
> > > John Clements
> > >
> > > >
> > > > The code I have so far looks like:
> > > >
> > > > (define (step-through-list lst)
> > > >(if (empty? lst)
> > > >lst
> > > >(cons (process-sublist (car lst)) (step-through-list (cdr lst)))
> > > >
> > > > but "car" would feed empty sublists to process-sublist as any other
> > > > sublist. How can I "silently" skip empty sublists and even get out of
> > > > the recursion without harm (if the last sublist is empty) without
> > > > switching to iteration?
> > > > Is there something like "car-not-empty" ? ;)
> > > > Or do I oversee the obvious here...? ;)))
> > > >
> > > > Thank you vary much for any help in advance!
> > > > Cheers
> > > > Meino
> > > >
> > > >
> > > > --
> > > > 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.
> > >
> >
> > --
> > 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails 

Re: [racket-users] Recursevly processing a list with "wholes"

2016-11-16 Thread David Storrs
On Wed, Nov 16, 2016 at 11:10 AM, David Storrs 
wrote:

> Hi Meino,
>
> As a suggestions, you might want to read through this page on Stack
> Overflow about how to ask technical questions:
> http://stackoverflow.com/help/how-to-ask   The summary is:  tell us what
> you're trying to achieve, what you've tried, and what *specifically* is not
> working.
>
> The question you're asking here (about walk-lists) is hard to help with,
> because it's not clear what the context is.  I'll take my best shot, though:
>
> On Wed, Nov 16, 2016 at 10:04 AM,  wrote:
>
>> Hi John,
>>
>> thank you for your reply ! :)
>>
>> ...no, not a homework...
>> I want to teach myself some racket and hope 'to get it' finally...
>> Since I am no native speaker I have the deficulty to search for
>> things, which names I dont know...
>>
>> One example of my code is:
>>
>> (define (trim-list lst)
>>   (if (empty? lst)
>> lst
>> (cons (string-trim (car lst)) (trim-list (cdr lst)
>>
>>
>> (define (walk-sublists lst)
>>   (if (empty? lst)
>> lst
>> (cons (trim-list (car lst)) (walk-sublists (cdr lst)
>>
>> I want to avoid to call trim-list, if 'car lst' returns an empty list.
>> Instead 'car lst' sghould return the next non-empty list...
>>
>> I will take a look in the reference manual for 'filter' and 'compose'.
>>
>> Cheers
>> Meino
>>
>>
>>
> You might try something like this:
>
> (define (trim-list lst)
>   (if (empty? lst)
> lst
> (cons (string-trim (car lst))
> (trim-list (cdr lst)
>


Dangit, GMail, hitting 'tab, space' does not necessarily mean I want to
send, it might just mean I want to indent some code.  Sorry for that, all.


(define (trim-list lst) ...)

;;  process a list, but skip any element of the list that is null
(define (walk-sublists lst)
   (cond[(null? lst) null]
[(null? (car lst)) (walk-lists (cdr lst))]
[else (cons (trim-list (car lst))
  (walk-sublists (cdr lst]))

Code not tested, but let me know if it makes sense.


Dave


>>
>>
>> 'John Clements' via Racket Users 
>> [16-11-16 18:26]:
>> >
>> > > On Nov 15, 2016, at 19:52, meino.cra...@gmx.de wrote:
>> > >
>> > > Hi,
>> > >
>> > > I have a list of sublists. Some of the sublists are empty.
>> > > The list should be processed recursevly and the resulting
>> > > list should no longer contain empty sublists.
>> >
>> > Is this homework?
>> >
>> > if so: can you show your test cases?
>> >
>> > if not: (filter (compose not null?) l).
>> >
>> >
>> > John Clements
>> >
>> > >
>> > > The code I have so far looks like:
>> > >
>> > > (define (step-through-list lst)
>> > >(if (empty? lst)
>> > >lst
>> > >(cons (process-sublist (car lst)) (step-through-list (cdr lst)))
>> > >
>> > > but "car" would feed empty sublists to process-sublist as any
>> other
>> > > sublist. How can I "silently" skip empty sublists and even get out of
>> > > the recursion without harm (if the last sublist is empty) without
>> > > switching to iteration?
>> > > Is there something like "car-not-empty" ? ;)
>> > > Or do I oversee the obvious here...? ;)))
>> > >
>> > > Thank you vary much for any help in advance!
>> > > Cheers
>> > > Meino
>> > >
>> > >
>> > > --
>> > > 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.
>> >
>>
>> --
>> 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] Recursevly processing a list with "wholes"

2016-11-16 Thread David Storrs
Hi Meino,

As a suggestions, you might want to read through this page on Stack
Overflow about how to ask technical questions:
http://stackoverflow.com/help/how-to-ask   The summary is:  tell us what
you're trying to achieve, what you've tried, and what *specifically* is not
working.

The question you're asking here (about walk-lists) is hard to help with,
because it's not clear what the context is.  I'll take my best shot, though:

On Wed, Nov 16, 2016 at 10:04 AM,  wrote:

> Hi John,
>
> thank you for your reply ! :)
>
> ...no, not a homework...
> I want to teach myself some racket and hope 'to get it' finally...
> Since I am no native speaker I have the deficulty to search for
> things, which names I dont know...
>
> One example of my code is:
>
> (define (trim-list lst)
>   (if (empty? lst)
> lst
> (cons (string-trim (car lst)) (trim-list (cdr lst)
>
>
> (define (walk-sublists lst)
>   (if (empty? lst)
> lst
> (cons (trim-list (car lst)) (walk-sublists (cdr lst)
>
> I want to avoid to call trim-list, if 'car lst' returns an empty list.
> Instead 'car lst' sghould return the next non-empty list...
>
> I will take a look in the reference manual for 'filter' and 'compose'.
>
> Cheers
> Meino
>
>
>
You might try something like this:

(define (trim-list lst)
  (if (empty? lst)
lst
(cons (string-trim (car lst))
(trim-list (cdr lst)
>
>
>
>
> 'John Clements' via Racket Users 
> [16-11-16 18:26]:
> >
> > > On Nov 15, 2016, at 19:52, meino.cra...@gmx.de wrote:
> > >
> > > Hi,
> > >
> > > I have a list of sublists. Some of the sublists are empty.
> > > The list should be processed recursevly and the resulting
> > > list should no longer contain empty sublists.
> >
> > Is this homework?
> >
> > if so: can you show your test cases?
> >
> > if not: (filter (compose not null?) l).
> >
> >
> > John Clements
> >
> > >
> > > The code I have so far looks like:
> > >
> > > (define (step-through-list lst)
> > >(if (empty? lst)
> > >lst
> > >(cons (process-sublist (car lst)) (step-through-list (cdr lst)))
> > >
> > > but "car" would feed empty sublists to process-sublist as any other
> > > sublist. How can I "silently" skip empty sublists and even get out of
> > > the recursion without harm (if the last sublist is empty) without
> > > switching to iteration?
> > > Is there something like "car-not-empty" ? ;)
> > > Or do I oversee the obvious here...? ;)))
> > >
> > > Thank you vary much for any help in advance!
> > > Cheers
> > > Meino
> > >
> > >
> > > --
> > > 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.
> >
>
> --
> 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] Recursevly processing a list with "wholes"

2016-11-16 Thread Matthias Felleisen

> On Nov 16, 2016, at 1:04 PM, meino.cra...@gmx.de wrote:
> 
> ...no, not a homework...
> I want to teach myself some racket and hope 'to get it' finally...
> Since I am no native speaker I have the deficulty to search for
> things, which names I dont know...


Meino, have you considered reading 'Die Macht der Abstraktion?’ (This is a 
guess based on your high-level domain.) — Matthias

-- 
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] Recursevly processing a list with "wholes"

2016-11-16 Thread Meino . Cramer
Hi John,

thank you for your reply ! :)

...no, not a homework...
I want to teach myself some racket and hope 'to get it' finally...
Since I am no native speaker I have the deficulty to search for
things, which names I dont know...

One example of my code is:

(define (trim-list lst)
  (if (empty? lst)
lst
(cons (string-trim (car lst)) (trim-list (cdr lst)


(define (walk-sublists lst)
  (if (empty? lst)
lst
(cons (trim-list (car lst)) (walk-sublists (cdr lst)

I want to avoid to call trim-list, if 'car lst' returns an empty list.
Instead 'car lst' sghould return the next non-empty list...

I will take a look in the reference manual for 'filter' and 'compose'.

Cheers
Meino





'John Clements' via Racket Users  [16-11-16 
18:26]:
> 
> > On Nov 15, 2016, at 19:52, meino.cra...@gmx.de wrote:
> > 
> > Hi,
> > 
> > I have a list of sublists. Some of the sublists are empty.
> > The list should be processed recursevly and the resulting
> > list should no longer contain empty sublists.
> 
> Is this homework? 
> 
> if so: can you show your test cases?
> 
> if not: (filter (compose not null?) l).
> 
> 
> John Clements
> 
> > 
> > The code I have so far looks like:
> > 
> > (define (step-through-list lst)
> >(if (empty? lst)
> >lst
> >(cons (process-sublist (car lst)) (step-through-list (cdr lst)))
> > 
> > but "car" would feed empty sublists to process-sublist as any other
> > sublist. How can I "silently" skip empty sublists and even get out of
> > the recursion without harm (if the last sublist is empty) without
> > switching to iteration?
> > Is there something like "car-not-empty" ? ;)
> > Or do I oversee the obvious here...? ;)))
> > 
> > Thank you vary much for any help in advance!
> > Cheers
> > Meino
> > 
> > 
> > -- 
> > 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.
> 

-- 
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] a litle help

2016-11-16 Thread Gustavo Massaccesi
The program has a few errors.

For example,

* (define O ( X0 Y0 ))

should be something like

(define O (make-point X0 Y0))
(define O (point X0 Y0))
(define O (vector X0 Y0))

I'm not sure because the first two don't exist and I guess the last one is
not what you want, but you must change that line to

(define O (something X0 Y0))

* (* cos dT 30)

I guess it should be (* (cos 30) dT)

but you have to transform the 30 degrees to radians.

--

My suggestion is to try first with an easier exercise. Try to draw a
balloon that doesn't move. It's boring but the program is easier. Once you
understand all the details about the framework to draw the non moving
balloon, you can add the movement.

Gustavo


On Wed, Nov 16, 2016 at 6:54 AM, Masto Fine 
wrote:

>  (define (ballon-tourne)
> (local [(define LARG 110 )
> (define HAUT 110 )
> (define SCENE (carre 100 100 'outline "black"))
> (define BALLON ( circle 5 'solid "red"))
> (define X0 (/ LARG 2))
> (define Y0 (/ HAUT 2 ))
> (define O ( X0 Y0 ))
> (define M ( XM YM ))
> (define P ((+ X0 30) Y0))
> (define t (angle OP OM ))
> (define INIT 0)
> (define dT 5)
> (define (suivant t)
>   ((+ X0 (* cos dT 30)( - Y0 (* sin dT )
> (define (dessiner t)
>   (place-image BALLON ( (+ X0 ( * cos t 30))(- Y0 (*sin t)
> (define (final? t)
>(= t 700))]
>   (big-bang INIT
> (on-tick suivant)
> (on-draw dessiner)
> (stop-when final?can you correct me :
>
> --
> 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] a litle help

2016-11-16 Thread Masto Fine
 (define (ballon-tourne)
(local [(define LARG 110 )
(define HAUT 110 )
(define SCENE (carre 100 100 'outline "black"))
(define BALLON ( circle 5 'solid "red"))
(define X0 (/ LARG 2))
(define Y0 (/ HAUT 2 ))
(define O ( X0 Y0 ))
(define M ( XM YM ))
(define P ((+ X0 30) Y0))
(define t (angle OP OM ))
(define INIT 0)
(define dT 5)
(define (suivant t)
  ((+ X0 (* cos dT 30)( - Y0 (* sin dT )
(define (dessiner t)
  (place-image BALLON ( (+ X0 ( * cos t 30))(- Y0 (*sin t)
(define (final? t)
   (= t 700))]
  (big-bang INIT
(on-tick suivant)
(on-draw dessiner)
(stop-when final?can you correct me :

-- 
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.