[racket-users] Re: Checking if two lists contain a word
Am Sonntag, 25. Juni 2017 19:40:08 UTC+2 schrieb philipp.t...@gmail.com: > 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) Thanks for the advice. I have no more question! :) -- 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
Thanks guys the tips made me have the idea that I can just write the check for the second list instead of '(true). Here is my solution: #lang racket (define (test1 word book book2) (cond ((null? book) '(false)) ((equal? word (first book)) (cond ((null? book2) '(false)) ((equal? word (first book2)) 'true) (else (test1 word book (rest book2) (else (test1 word (rest book) book2 Thanks you again -- 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
Am Sonntag, 25. Juni 2017 14:24:27 UTC+2 schrieb philipp.t...@gmail.com: > 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! Thanks guys for the help! -- 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
Hello I tried another version but it doesnt work. Can anyone help me? Using the "and" function didnt help me. #lang racket (define (checker wort liste1 liste2) (cond ((and (equal? (first liste1) wort) (equal? (first liste2) wort)) '(true)) ((or (null? liste1) (null? liste2)) '(false)) ((equal? (first liste1) wort) (checker wort (rest liste2) (rest liste2))) ((equal? (first liste2) wort) (checker wort (rest liste1) (rest liste1) -- 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
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.
[racket-users] Re: I can translate a word but how can I translate a setence with drrakket
Thanks for all the answers but I have to say that it has to be in one function and that I can only use this tools (https://pastebin.com/en3E4aTA). I tried solving this for hours so please help 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.
[racket-users] Checking if two lists contain a word
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] 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.