Re: [racket-users] Re: How to convert String to Integer

2020-02-11 Thread Philip McGrath
On Tue, Feb 11, 2020 at 3:28 PM Alain De Vos wrote: > But first i need a list of characters. :) > Does the language has a conversion operator ? > Yes, `string->list`: https://docs.racket-lang.org/reference/strings.html#(def._((quote._~23~25kernel)._string-~3elist)) But read on … On Tue, Feb

Re: [racket-users] Re: How to convert String to Integer

2020-02-11 Thread Sorawee Porncharoenwase
You can convert a string to a list of characters by using string->list. The code snippet that you presented in your very first post also uses this function. > (string->list "abc") - : (Listof Char) '(#\a #\b #\c) What I want to ask you though is what is wrong with the code that Phillip

[racket-users] Re: How to convert String to Integer

2020-02-11 Thread Alain De Vos
In C I would would do some very simple pointer arithmetic, but racket leaves me into the blue. Documentation, which is fine, compared to other lisps, fyi chez, leaves me into the blue. 0) Given a string, 1) convert to a list of characters, 2) allow me to iterate, 3) convert a character to an

[racket-users] Making -doc/-lib packages?

2020-02-11 Thread Stephen De Gabrielle
Ok Turns out the better approach is to use the Built Package server with raco pkg install —binary-lib packagename https://pkg-build.racket-lang.org/about.html :) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group

[racket-users] Re: How to convert String to Integer

2020-02-11 Thread Alain De Vos
Very basic question, first step first, how do i convert a string astring to a list of characters, #lang typed/racket (require typed/racket/gui) (: astring String) (define astring "1234567890") On Tuesday, February 11, 2020 at 11:34:16 AM UTC+1, Alain De Vos wrote: > > I tried the following

[racket-users] Making -doc/-lib packages?

2020-02-11 Thread Stephen De Gabrielle
Is there a guide to making packages with -doc & -lib versions so you can require the package-lib without getting/building the documentation? Best, Stephen -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Alain De Vos
Philip, For the last part, I will make my work through, convert a string to collection/list of characters, this to a collection/list of numbers with a value 48 subtracted i think, this to the correct end value base10. I have no complex numbers to deal with. But at each step I should raise , this

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Alain De Vos
On Tuesday, February 11, 2020 at 5:33:37 PM UTC+1, Philip McGrath wrote: > > Others have tried to be more Socratic in pointing you this way, but here's > an attempt at being more explicit. > > As you note, the result of `string->number` has the type `(U Complex > False)`. If we try to think

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Philip McGrath
Others have tried to be more Socratic in pointing you this way, but here's an attempt at being more explicit. As you note, the result of `string->number` has the type `(U Complex False)`. If we try to think about about this in a version of the HtDP design recipe, we have a few cases: 1.

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Alain De Vos
No exact-integer is a check it is not a type. The error described above remains On Tuesday, February 11, 2020 at 3:50:27 PM UTC+1, Alain De Vos wrote: > > > > On Tuesday, February 11, 2020 at 3:25:42 PM UTC+1, Ben Greenman wrote: >> >> You may want `exact-integer?` >> True , i should use

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Alain De Vos
On Tuesday, February 11, 2020 at 3:25:42 PM UTC+1, Ben Greenman wrote: > > You may want `exact-integer?` > True , i should use exact-integer. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Ben Greenman
You may want `exact-integer?` -- 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. To view this discussion on the web

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Alain De Vos
Indeed good question, but the following code works, #lang typed/racket (require typed/racket/gui) (: fib (-> Integer Integer)) (define (fib n) (if (< 2 n) n (+ (fib (- n 1)) (fib (- n 2) (: numericalchar2integer (-> Char Integer)) (define (numericalchar2integer char)

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Ryan Culpepper
What should `(myconversion "apple")` return? What should `(myconversion "12.3")` return? What does `string->number` do in each of those cases? Ryan On Tue, Feb 11, 2020 at 11:34 AM Alain De Vos wrote: > I tried the following function to conver a String to an Integer. > > #lang typed/racket >

[racket-users] Re: How to convert String to Integer

2020-02-11 Thread Alain De Vos
Or is it they idea to write own conversion functions to learn the language. -- 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] How to convert String to Integer

2020-02-11 Thread Alain De Vos
I tried the following function to conver a String to an Integer. #lang typed/racket (: myconversion (-> String Integer)) (define (myconversion str) (string->number str)) The error given is : Type Checker: type mismatch expected: Integer given: (U Complex False) in: (string->number str) I