badkins
2020-7-1 13:59:47

Right, the first link I posted above has info on how to use app passwords, etc. Although, that seems to only be necessary if two factor is enabled.


chansey97
2020-7-1 14:31:18

Is there way to car a string or pattern match a string’s head and rest? e.g. (car "string")


samth
2020-7-1 14:34:07

You can use string-ref.


soegaard2
2020-7-1 14:35:34

Consider using string->list then work on the list instead.


chansey97
2020-7-1 14:40:40

@samth it can get head of string, but how to get rest of string?

I found there is function called string->immutable-string , but it still a string. (no car/head cdr/tail function provided)

@soegaard2 This works, thanks.


badkins
2020-7-1 14:43:21

@chansey97 (define (car-str str) (substring str 0 1)) (define (cdr-str str) (substring str 1))


brentgordon146
2020-7-1 14:43:44

@badkins no i dont have two factor enabled


brentgordon146
2020-7-1 14:44:42

@zenspider how did you create an app specific password?


chansey97
2020-7-1 14:44:48

@badkins yes, but it can not be pattern matched.


badkins
2020-7-1 14:45:47

Why not?


samth
2020-7-1 14:46:39

I would also suggest that usually processing strings character-by-character is not the right approach — string-ref (and similarly substring and string->list) doesn’t handle more complicated cases like combining characters.


chansey97
2020-7-1 14:46:58

sorry, I am not familiar with pattern matching. But you provide two functions, so we must use if else to check the return value.


badkins
2020-7-1 14:48:46

Are you wanting something like Haskell’s pattern match on x:xs for strings?


soegaard2
2020-7-1 14:48:52

chansey97
2020-7-1 14:49:43

@badkins yes It would be nice, if we can do (match some-string [() ......] [(x xs) ......])


badkins
2020-7-1 14:54:42

I wouldn’t be surprised if you’re able to create a custom matcher to handle what you want, but I’d probably just use: (cond [(empty-string? str) ... ] [else ... ])


samth
2020-7-1 14:55:13

You can do: (match s [(app list->string (list)) ...] [(app list->string (cons x xs)) ...])


brentgordon146
2020-7-1 14:56:02

they can only be used with two factor authentication accounts


badkins
2020-7-1 14:56:36

eeewww :slightly_smiling_face:


samth
2020-7-1 14:57:49

You can also do: (define-match-expander str (syntax-rules () [(_ p) (app list->string p)])) (match s [(str (list)) ...] [(str (cons x xs)) ...])


chansey97
2020-7-1 15:00:28

@samth In your first example, the x and xs are bounded? it is surprising! Could you give me some referece of app ? I’m sorry, the keyword app is not friendly to search engine.



samth
2020-7-1 15:02:39

But again, I want to encourage you to think about whether character-by-character processing is really the right thing. For example, what is the first character in ":jp:"?


samth
2020-7-1 15:03:36

Because the result from string-ref is #\🇯


chansey97
2020-7-1 15:04:04

@samth Yes, finally will preprocess the string by using list->string, and use list instead.


badkins
2020-7-1 15:05:22

I’m guessing @samth meant string->list above


samth
2020-7-1 15:05:38

yes


chansey97
2020-7-1 15:05:38

@badkins yes.


chansey97
2020-7-1 15:05:42

just typo..


chansey97
2020-7-1 15:06:53

@samth I am just writing a toy parser by functional way in racket, I don’t want to use cursor for the position of the string.


chansey97
2020-7-1 15:13:56

@samth What do you mean by For example, what is the first character in ":jp:"?  Does string->list support unicode?


samth
2020-7-1 15:14:36

What do you mean by “support unicode”? string-length of that string produces 2.


samth
2020-7-1 15:15:03

Flags (and many other emoji) are made up of multiple combining characters.


chansey97
2020-7-1 15:16:08

@samth OK, that’s not a problem.


chansey97
2020-7-1 15:19:30

@samth but wait, Does Emoji and Unicode overlap? For example:


chansey97
2020-7-1 15:19:42

Is this unicode?


chansey97
2020-7-1 15:19:46

samth
2020-7-1 15:19:55

yes, all the characters you see anywhere are unicode


chansey97
2020-7-1 15:19:58

:grinning: <— this is emoji from Slack


samth
2020-7-1 15:22:14

yes, and it’s a unicode character


chansey97
2020-7-1 15:22:59

OMG! emojis are exactly unicode characters? I did not know before…


samth
2020-7-1 15:23:38

well, “character” is a complicated concept, and some emoji (like that flag) are made up of multiple characters (in some senses)


chansey97
2020-7-1 15:23:51

But I copy this face in slack, it give me ": grinning :"


samth
2020-7-1 15:24:07

that’s how you can type it in slack


chansey97
2020-7-1 15:26:30

@samth I used to think emoji were just ASCII characters, and the text renderer parse these characters between ::. Thank you for telling me this knowledge!


chansey97
2020-7-1 15:34:43

I copied a japanese flag from https://emojipedia.org/flag-japan/ to Emacs.


chansey97
2020-7-1 15:34:56

It return 2.


chansey97
2020-7-1 15:35:20

It’s amazing.


chansey97
2020-7-1 15:36:15

In slack, we just type :jp: