I came to the following result as conversion function :
#lang typed/racket
(: string2value (-> String Integer))
(define (string2value astring)
(define (fun [val : Char] [res : Integer])
(+ (* 10 res) (- (char->integer val) 48)))
(foldl fun 0 (string->list astring))
)
(print (string2value "
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 11,
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
suggested?
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
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 funct
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+unsubscr...@googlegroups
6 matches
Mail list logo