[racket-users] Re: Removing undocumented exports of rackunit/text-ui

2017-06-25 Thread Jack Firth
On Monday, June 12, 2017 at 11:55:31 AM UTC-7, Jack Firth wrote:
> The rackunit/text-ui module[1] provides `run-tests` along with a handful of 
> other random undocumented functions with unclear purposes such as 
> `display-ticker`. I have a PR to rackunit open[2] that removes the 
> undocumented exports (it does *not* remove `run-tests`). So far I've found no 
> callers of these functions with Github search, but if you happen to use them 
> please speak up so I don't merge a PR that breaks your code. If you have 
> historical insight into this module and these exports, please comment on the 
> PR so I know more about what I'm removing.
> 
> [1] 
> http://docs.racket-lang.org/rackunit/api.html?q=rackunit%2Ftext-ui#%28mod-path._rackunit%2Ftext-ui%29
> [2] https://github.com/racket/rackunit/pull/34

Just a heads up that after no responses for two weeks, this is now being 
merged. To any users of rackunit nightly, look out for weird missing export 
failures.

-- 
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] DrRacket Font Selection

2017-06-25 Thread Lehi Toskin
Since there is only a single choice, on-subwindow-event (line 86) will not be 
executed by simply clicking, I need to wheel-up or wheel-down for it to update 
the list of fonts. Pressing Enter, however, forces on-subwindow-char (line 92) 
to execute and populate the list of fonts. Selecting the font I want and 
restarting DrRacket will keep my font intact, but the list of fonts is once 
again reduced to a single option - this time my font instead of Monospace. I 
believe it has something to do with `preferences:get` call on line 99, but I'm 
not familiar enough with the framework library to think of a reason why it 
would be acting improperly.

-- 
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: inspecting a table error 'error 'query: multiple statements given'

2017-06-25 Thread Alexander McLin
FYI, the misleading "multiple statements given" error has been fixed in the 
racket master branch and correct syntax error message is now being raised.

-- 
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: Checking if two lists contain a word

2017-06-25 Thread Vityou
Try taking a look at the `and` function: 
https://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29

On Sunday, June 25, 2017 at 11:40:08 AM UTC-6, philipp.t...@gmail.com wrote:
> Hello its me again,
> 
> I have the task to make a funcition who checks if two lists contain a word.
> 
> I made a function which does that with one lst but I dont find a way to do it 
> with two lists. There must be some easy trick but I dont find it.
> 
> The function has to look like this: (test2 word list1 list2) and its only 
> allowed to use one function.
> 
> Here is my function for checking one list. Can someone edit it so I can make 
> it with two lists? Would help me alot.
> 
> 
> 
> 
> #lang racket
> 
> 
> (define (test1 word book)
> 
>   (cond ((null? book) '(false))
> 
> ((equal? word (first book)) '(true))
> 
> (else (test1 word (rest book)

-- 
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: I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread Matthias Felleisen

> On Jun 25, 2017, at 4:28 PM, Philip McGrath  wrote:
> 
> At this point it is mostly a question of how restrictive your teacher wishes 
> to be by requiring that you implement this as a single function. If you are 
> using full Racket, it is possible to define a helper function inside of a 
> larger function. Here is the most direct way to translate your existing code:
> 
> #lang racket
> 
> (define *lex*
>   '((cat gato katze)
> (dog perro hund)
> (eats come frisst)
> (jumps salte springt)
> (the el die)))
> 
> (define (translate-sentence satz lexikon sprache)



May I point out that this version introduces (“creates”) a new version of 
translate-word for every “iteration” of translate-sentence even though these 
versions are all the same (observationally)? 


>   (define (translate-word wort lexikon sprache)
> (cond
>   [(null? lexikon)
>'(Wort wurde nicht gefunden)]
>   [(or (equal? wort (first (first lexikon)))
>(equal? wort (first (rest (first lexikon
>(equal? wort (first (rest (rest (first lexikon))
>(cond
>  [(equal? sprache 'english)
>   (first (first lexikon))]
>  [(equal? sprache 'spanisch)
>   (first (rest (first lexikon)))]
>  [(equal? sprache 'deutsch)
>   (first (rest (rest (first lexikon])]
>   [else
>(translate-word wort (rest lexikon) sprache)]))
>   (cond
> [(null? satz) '()]
> [else
>  (cons (translate-word (first satz) lexikon sprache)
>(translate-sentence (rest satz) lexikon sprache))]))
> 
> Can you see a way to make remove the sprache argument from translate-word?
> 
> -Philip
> 
> On Sun, Jun 25, 2017 at 3:03 PM,  > wrote:
> Thanks guys I got a solution!
> 
> #lang racket
> 
> 
> 
> (define *lex*
> '((catgato   katze)
>   (dog   perro  hund)
>   (eats   come  frisst)
>   (jumps   salte   springt)
>   (the   el   die)))
> 
> 
> (define (translator wort lexikon sprache)
> 
>   (cond ((null? lexikon) '(Wort wurde nicht gefunden))
> 
> ((or (equal? wort (first (first lexikon)))
> 
>  (equal? wort (first (rest (first lexikon
> 
>  (equal? wort (first (rest (rest (first lexikon))
> 
> 
>(cond
>  ((equal? sprache 'english) (first (first lexikon)))
> 
>  ((equal? sprache 'spanisch) (first (rest (first lexikon
> 
>  ((equal? sprache 'deutsch) (first (rest (rest (first lexikon))
> 
> )
> 
> 
> (else (translator wort (rest lexikon) sprache))
> 
> ))
> 
>(define (translate2 satz lexikon sprache)
>  (cond((null? satz) '())
>   (else (cons (translator (first satz) *lex* sprache) (translate2 
> (rest satz) lexikon sprache)
> 
> 
> So now I just wanna know if there is a way to make this in one function?
> Is it possible to make a function inside a function and if yes how?
> 
> --
> 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] Re: I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread Philip McGrath
At this point it is mostly a question of how restrictive your teacher
wishes to be by requiring that you implement this as a single function. If
you are using full Racket, it is possible to define a helper function
inside of a larger function. Here is the most direct way to translate your
existing code:

#lang racket

(define *lex*
  '((cat gato katze)
(dog perro hund)
(eats come frisst)
(jumps salte springt)
(the el die)))

(define (translate-sentence satz lexikon sprache)
  (define (translate-word wort lexikon sprache)
(cond
  [(null? lexikon)
   '(Wort wurde nicht gefunden)]
  [(or (equal? wort (first (first lexikon)))
   (equal? wort (first (rest (first lexikon
   (equal? wort (first (rest (rest (first lexikon))
   (cond
 [(equal? sprache 'english)
  (first (first lexikon))]
 [(equal? sprache 'spanisch)
  (first (rest (first lexikon)))]
 [(equal? sprache 'deutsch)
  (first (rest (rest (first lexikon])]
  [else
   (translate-word wort (rest lexikon) sprache)]))
  (cond
[(null? satz) '()]
[else
 (cons (translate-word (first satz) lexikon sprache)
   (translate-sentence (rest satz) lexikon sprache))]))


Can you see a way to make remove the sprache argument from translate-word?

-Philip

On Sun, Jun 25, 2017 at 3:03 PM,  wrote:

> Thanks guys I got a solution!
>
> #lang racket
>
>
>
> (define *lex*
> '((catgato   katze)
>   (dog   perro  hund)
>   (eats   come  frisst)
>   (jumps   salte   springt)
>   (the   el   die)))
>
>
> (define (translator wort lexikon sprache)
>
>   (cond ((null? lexikon) '(Wort wurde nicht gefunden))
>
> ((or (equal? wort (first (first lexikon)))
>
>  (equal? wort (first (rest (first lexikon
>
>  (equal? wort (first (rest (rest (first lexikon))
>
>
>(cond
>  ((equal? sprache 'english) (first (first lexikon)))
>
>  ((equal? sprache 'spanisch) (first (rest (first lexikon
>
>  ((equal? sprache 'deutsch) (first (rest (rest (first lexikon))
>
> )
>
>
> (else (translator wort (rest lexikon) sprache))
>
> ))
>
>(define (translate2 satz lexikon sprache)
>  (cond((null? satz) '())
>   (else (cons (translator (first satz) *lex* sprache) (translate2
> (rest satz) lexikon sprache)
>
>
> So now I just wanna know if there is a way to make this in one function?
> Is it possible to make a function inside a function and if yes how?
>
> --
> 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: I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread philipp . thiess1999
Thanks guys I got a solution!

#lang racket



(define *lex*
'((catgato   katze)
  (dog   perro  hund)
  (eats   come  frisst)
  (jumps   salte   springt)
  (the   el   die)))


(define (translator wort lexikon sprache)

  (cond ((null? lexikon) '(Wort wurde nicht gefunden))

((or (equal? wort (first (first lexikon)))

 (equal? wort (first (rest (first lexikon

 (equal? wort (first (rest (rest (first lexikon))


   (cond
 ((equal? sprache 'english) (first (first lexikon)))

 ((equal? sprache 'spanisch) (first (rest (first lexikon

 ((equal? sprache 'deutsch) (first (rest (rest (first lexikon))

)  
   

(else (translator wort (rest lexikon) sprache))

))

   (define (translate2 satz lexikon sprache)
 (cond((null? satz) '())
  (else (cons (translator (first satz) *lex* sprache) (translate2 (rest 
satz) lexikon sprache)


So now I just wanna know if there is a way to make this in one function?
Is it possible to make a function inside a function and if yes how?

-- 
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] DrRacket Font Selection

2017-06-25 Thread Robby Findler
Oh, looking at the code, I can see how that could happen if something
has gone wrong with the callbacks in the GUI. Take a look at
drracket/private/font, and see the function `force-cache`, roughly
lines 71-86. That function is supposed to be called, but I guess some
callbacks aren't firing for you and thus it isn't being called.

Maybe if you stick some printfs in there you'll get some useful
information that would help us debug racket/gui?

Robby


On Sun, Jun 25, 2017 at 2:32 PM, Lehi Toskin  wrote:
> Yeah, that's exactly where I'm looking. In the Font Name, I see only 
> Monospace. I click on it and there are no choices except that one.
>
> --
> 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] DrRacket Font Selection

2017-06-25 Thread Lehi Toskin
Yeah, that's exactly where I'm looking. In the Font Name, I see only Monospace. 
I click on it and there are no choices except that one.

-- 
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] threading macros

2017-06-25 Thread Alexis King
As written, the simple answer to your question is to use begin0 or
begin, depending on if you are using ~> or ~>>.

> (~> 3 (begin0 (displayln "hi!")) (* 2))
hi!
6

But as Greg mentions, this is not very useful, and it probably isn’t
what you want, since the evaluated expression can only be evaluated for
side-effects, which is rather against the spirit of threading macros
altogether.

It is a little difficult for me to imagine what a hypothetical syntax
for your use-case would look like without turning ~> into a much more
complicated binding form. As it is, the threading macros are all quite
simple, and they are simple shorthands for syntactic nesting. It would
be possible to generalize them quite a bit, but I am fond of their
simplicity, and I think Greg’s suggestion to just use let* is a good
one. I’m not sure there is a good way to synthesize the brevity and
simplicity of threading with a more powerful binding form, though if you
can come up with a syntax that accomplishes what you’re getting at, I’d
certainly at least be interested by it.

> On Jun 25, 2017, at 09:44, Sanjeev Sharma  wrote:
> 
> is there a way to do a calculation in the middle of the chain that
> takes no arguments?  In other words, exempt some operations in the
> chain from taking any arguments.
> 
> Suppose one's doing a calculation of interest earned on an investment
> and one is threading a running balance through the chain, but at
> places one needs a calculation for purchases and/or dispositions to
> the investment.

-- 
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] DrRacket Font Selection

2017-06-25 Thread Robby Findler
DrRacket's font configuration is the first pane in the preferences
dialog; you will probably find it at the bottom of the Edit menu, I
guess?

If that wasn't where you were looking when you were talking about
DrRacket's decision making earlier, can you elaborate please?

Robby


On Sun, Jun 25, 2017 at 1:37 PM, Lehi Toskin  wrote:
> Where is "Other..."? I don't see it anywhere. Also, `(get-face-list 'mono)` 
> shows a whole lot more fonts than just Monospace.
>
> On Sunday, June 25, 2017 at 3:33:22 AM UTC-7, Robby Findler wrote:
>> DrRacket uses the result of (get-face-list 'mono) in its dialog. If
>> you choose "Other..." you should be able to choose from the same set
>> that get-font-from-user uses.
>>
>> 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.

-- 
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] DrRacket Font Selection

2017-06-25 Thread Lehi Toskin
Where is "Other..."? I don't see it anywhere. Also, `(get-face-list 'mono)` 
shows a whole lot more fonts than just Monospace.

On Sunday, June 25, 2017 at 3:33:22 AM UTC-7, Robby Findler wrote:
> DrRacket uses the result of (get-face-list 'mono) in its dialog. If
> you choose "Other..." you should be able to choose from the same set
> that get-font-from-user uses.
> 
> 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] Re: threading macros

2017-06-25 Thread Greg Hendershott
This might not be a good fit for threading macros.

If you need to calculate some extra, intermediate values, I
definitely wouldn't recommend `set!`-ing them on the side in a
threading macro (if that's what you had in mind).

Threading macros produce a single value.

If you need to produce multiple values, you could aggregate them
into a single value like a `struct` or `list`, and thread _that_.
Assuming you have functions that take it.

But if you have "intermediate" values that are undefined until a
certain point in the calculation? It sounds like you simply want
to use named variables for each step of the calculation.

(define principal 10.0)
(define rate 0.05)
(define interest (* principal rate))
(define return (+ principal interest))
(define flat-fee 1.00)
(define net-return (- return flat-fee))


Maybe you don't like typing `define` so much? Or, maybe many of
the steps don't have an obvious meaningful name? In that case, an
alternative to a threading macro is the "classic" `let*` idiom
where you keep shadowing the same short, meaningless name:

(let* ([v 10.0]
   [v (v * 1.05)]
   [v (* v rate)]
   [something-else (+ v 42)]
   [v (* v 100)])
  ;; use `v` and `something-else`
  )

Each line binds a new `v` that shadows the previous one. (In
something like `[v (v * 1.05]` the `v` on the right-hand side is
still the value from the previous binding.)

Whether this is clearer is a matter of taste.


p.s. If you're dealing with money, of course don't use floating
point like I did above! (Because rounding errors.)

-- 
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] Checking if two lists contain a word

2017-06-25 Thread philipp . thiess1999
Hello its me again,

I have the task to make a funcition who checks if two lists contain a word.

I made a function which does that with one lst but I dont find a way to do it 
with two lists. There must be some easy trick but I dont find it.

The function has to look like this: (test2 word list1 list2) and its only 
allowed to use one function.

Here is my function for checking one list. Can someone edit it so I can make it 
with two lists? Would help me alot.




#lang racket


(define (test1 word book)

  (cond ((null? book) '(false))

((equal? word (first book)) '(true))

(else (test1 word (rest book)

-- 
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] noob question: generic interfaces & classes

2017-06-25 Thread Matthew Butterick
How does one attach a generic interface to a class?

`class*` allows one to attach an `interface` [2] (in the class sense of that 
term, which I understand is separate from that of "generic interface"). 

Then the docs for `interface*` show an example attaching the 
`prop:custom-write` property. [3] But the docs for `prop:custom-write` say that 
it's deprecated, and one should "use `gen:custom-write`, instead" [4] (that is, 
the generic-interface version this concept).

Yet I when I put `gen:custom-write` into `interface*`, it triggers an "illegal 
use of syntax" error.

#lang racket

(define i<%> (interface* () ([gen:custom-write
  (lambda (obj port mode) (void))])
   method1 method2 method3))

So I'm not clear whether I'm doing it wrong, or if `interface*` only works with 
the (deprecated) property-based technique.



[2] 
http://docs.racket-lang.org/reference/createinterface.html?q=class*#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._interface%29%29
 


[3] 
http://docs.racket-lang.org/reference/createinterface.html?q=class*#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._interface%2A%29%29
 


[4] 
http://docs.racket-lang.org/reference/Printer_Extension.html?q=class*#%28def._%28%28quote._~23~25kernel%29._prop~3acustom-write%29%29
 


-- 
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] I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread Matthias Felleisen


I think you want this: 

#lang racket

(define *lex*
  '((cat   gato   katze)
(dog   perro  hund)
(eats  come   frisst)
(jumps salte  springt)
(the   el die)))

;; I also took the liberty of cleaning up your original code, 
;; using full Racket because it is what your teacher/you chose 
(define (translator wort lexikon sprache)
  (cond ((null? lexikon) '(Wort wurde nicht gefunden))
((member wort (first lexikon))
 ((sprache->selector sprache) (first lexikon)))
(else (translator wort (rest lexikon) sprache

(define (sprache->selector sprache)
  (cond
((equal? sprache 'english)  first ) 
((equal? sprache 'spanisch) second) 
((equal? sprache 'deutsch)  third)))

;; the code you want: 
(define (translator* worte lexikon sprache)
  (map (lambda (ein-wort) (translator ein-wort lexikon sprache)) worte))

;; the example: 
(translator* '(the dog jumps) *lex* 'deutsch)


The question you should ask now is how to get from here to there 
systematically. It is never about coding, but always about finding the code 
systematiclly. 

See http://www.ccs.neu.edu/home/matthias/HtDP2e/index.html





> On Jun 25, 2017, at 8:24 AM, philipp.thiess1...@gmail.com wrote:
> 
> Hello today I made a translator for drRakket cause its a task of my teacher.
> 
> 
> 
> I did it for one word but now I have to make it with a whole setence. I know 
> I have to work with cons somehow but I just dont get how to make it. My 
> teacher doesnt understand it himself (he uses a pdf which gives all the tasks 
> and wont give us solutuions) so you guys are my only hope.
> 
> 
> Here is my current code (Sorry for the german ( wort means word, lexikon is 
> the list with all the words in 3 langauges) and sprache means language)
> 
> 
> 
> #lang racket
> 
> (define *lex*
> '((catgato   katze)
>  (dog   perro  hund)
>  (eats   come  frisst)
>  (jumps   salte   springt)
>  (the   el   die)))
> 
> 
> (define (translator wort lexikon sprache)
> 
>  (cond ((null? lexikon) '(Wort wurde nicht gefunden)) 
> 
>((or (equal? wort (first (first lexikon))) 
> 
> (equal? wort (first (rest (first lexikon 
> 
> (equal? wort (first (rest (rest (first lexikon))
> 
> 
>   (cond
> ((equal? sprache 'english) (first (first lexikon))) 
> 
> ((equal? sprache 'spanisch) (first (rest (first lexikon 
> 
> ((equal? sprache 'deutsch) (first (rest (rest (first lexikon)) 
> 
>)  
> 
> 
> 
> 
>(else (translator wort (rest lexikon) sprache)) 
> 
>))
> 
> 
> So (translator 'cat *lex* 'deutsch) will give the german word for cat which 
> is Katze.
> 
> 
> But now I have to change the code that (translator '(the dog jumps) *lex* 
> 'deutsch) will give me "die hund springt".
> 
> Can anyone help me? You are my last hope!
> 
> 
> 
> -- 
> 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] I can translate a word but how can I translate a setence with drrakket

2017-06-25 Thread Jos Koot
Surely this is homework.
I am not giving you all detauils, just some hints.
First of all: Look in HtDP.

Your translator works for single words.
Let translate-sentence be the procedure for translating a list of words.
Following HtDP it can look like:

(define (translate-sentence sentence lexicon sprache)
 (cond 
  ((null? sentence) ...)
  ((else
(cons 
 (translate (car sentence) ...)
 (translate-sentence (cdr sentence) ...)

There are many more ways to do the same.
If you are acquanted with procedure map, you could write something like:

(define (translate-sentence sentence lexicon sprache)
 (define (translate-word word) (translate word lexicon spache))
 (map ...))

Jos

-Original Message-
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of philipp.thiess1...@gmail.com
Sent: domingo, 25 de junio de 2017 14:24
To: Racket Users
Subject: [racket-users] I can translate a word but how can I translate a 
setence with drrakket

Hello today I made a translator for drRakket cause its a task of my teacher.



I did it for one word but now I have to make it with a whole setence. I know I 
have to work with cons somehow but I just dont get
how to make it. My teacher doesnt understand it himself (he uses a pdf which 
gives all the tasks and wont give us solutuions) so you
guys are my only hope.


Here is my current code (Sorry for the german ( wort means word, lexikon is the 
list with all the words in 3 langauges) and sprache
means language)



#lang racket

(define *lex*
'((catgato   katze)
  (dog   perro  hund)
  (eats   come  frisst)
  (jumps   salte   springt)
  (the   el   die)))


(define (translator wort lexikon sprache)

  (cond ((null? lexikon) '(Wort wurde nicht gefunden)) 

((or (equal? wort (first (first lexikon))) 

 (equal? wort (first (rest (first lexikon 

 (equal? wort (first (rest (rest (first lexikon))


   (cond
 ((equal? sprache 'english) (first (first lexikon))) 

 ((equal? sprache 'spanisch) (first (rest (first lexikon 

 ((equal? sprache 'deutsch) (first (rest (rest (first lexikon)) 

)  




(else (translator wort (rest lexikon) sprache)) 

))


So (translator 'cat *lex* 'deutsch) will give the german word for cat which is 
Katze.


But now I have to change the code that (translator '(the dog jumps) *lex* 
'deutsch) will give me "die hund springt".

Can anyone help me? You are my last hope!



-- 
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] DrRacket Font Selection

2017-06-25 Thread Robby Findler
DrRacket uses the result of (get-face-list 'mono) in its dialog. If
you choose "Other..." you should be able to choose from the same set
that get-font-from-user uses.

Robby


On Sun, Jun 25, 2017 at 12:34 AM, Lehi Toskin  wrote:
> At some point DrRacket decided it didn't want to use any font other than 
> Monospace. In fact, Monospace is the only font that is available in the menu. 
> `(get-font-from-user)` will correctly display all my fonts, but for whatever 
> reason DrRacket doesn't want to cooperate. I've even tried using a fresh 
> .racket directory, but the result is the same.
>
> --
> 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.