![]() ![]() Hi, I have coached several teams on using Racket in programming contests. [(list (app string->number x) y (app string->number z)) (match (string-split (trim-brackets ln) ", ") Matthew, your solution is clever :) (but with symbols instead of strings).Īnother alternative could be to use match: How you guys are actually doing IO in racket ?Ī "read" variant that works with format strings would be a useful (string-scan "" "") -> '(45 "foo" 10.9)Īnd a proper output formatter would be comfy.Īre racket devs against such a thing in the standard library ? Having something like (not necessary the same specifiers as with printf) (define rows (string->number (read-line))) This is way more tedious than with the classical input/output format, especially when you are doing coding challenges. (~a a #:width 2 #:align 'right #:pad-string "0") ![]() Then you have to manually convert the values back into strings (define c (string->number (fourth split-row))) (define a (string->number (second split-row))) Then you have to manually convert the substrings into values (define split-row (regexp-match #rx"\\" (read-line))) The best that i have found to do that is using regular expressions. Then, for all rows, read and split the string. When doing programming challenges, you often need to comply to a specific input/ouput thus having something like scanf for string to values and printf for values to string is comfy.įor example, let's say a challenge where you simply have to output the input but you need to translate the strings input into values and then those values back to strings.įor (unsigned int i i number (read-line))) I recently started using Racket and i couldn't find a good alternative to C's scanf/printf in the racket standard library. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |