Does anybody know of a way to calculate a sequence of characters, perhaps using either the seq(), $ or .. functions? I could not find a function to use in the seq() function, and nothing that I tried using the $ and .. worked.
Did I miss a function that can be used in seq()? Is there a way to use $ and .. that will work?
Is there some other way altogether that I can use to create a character sequence?
You could try:
> convert([seq(i,i=65..65+25)],bytes); "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > convert([seq(i,i=97..97+25)],bytes); "abcdefghijklmnopqrstuvwxyz" > convert(%,bytes); [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
Characters in Maple are the same as single-letter strings. I don’t know what your difficulty is, unless you’re using a version of Maple before Release 5 (where the string type was first introduced). You can use, e.g.
Well, I hope that the following will help you:
> restart; > seed:=randomize(); seed := 993172925 > rg:=rand(1..52): > chars:=convert([$65..90,$97..122],bytes); chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" > seq(chars[rg()],i=1..20); "D", "g", "N", "e", "V", "c", "r", "p", "L", "j", "T", "l", "f", "E", "h", "N", "M", "X", "v", "e" > password1:=cat(``,%); password1 := DgNeVcrpLjTlfEhNMXve > password2:=cat(%%); password2 := "DgNeVcrpLjTlfEhNMXve"
Don’t use single letter names when doing the following:
> seq(convert(chars[rg()],name),i=1..20); e, k, x, M, y, F, u, f, X, T, R, m, N, V, w, p, L, R, d, i > password3:=cat(%); password3 := ekxMyFufXTRmNVwpLRdi > password4:=cat("",%%); password4 := "ekxMyFufXTRmNVwpLRdi"
It’s not entirely clear what you want... Perhaps something like this?
> str1 := ""; str1 := "" > for x from "a" to "z" by 2 do str1 := cat(str1,x) od: > str1; "acegikmoqsuwy" > str1[3..7]; "egikm"
Or perhaps this?
> alphabet := "abcdefghijklmnopqrstuvwxyz": > seq(alphabet[i],i=3..5); "c", "d", "e" > cat(%); "cde"
Here’s 6 distinct ways to create sequences of single-character strings:
> $ "d".."m"; "d", "e", "f", "g", "h", "i", "j", "k", "l", "m" > seq(i, i= "A string."); "A", " ", "s", "t", "r", "i", "n", "g", "." > "A string."[i] $ i= 3..8; "s", "t", "r", "i", "n", "g" > S:= NULL: for i in "A string." do S:= S, i od: S; "A", " ", "s", "t", "r", "i", "n", "g", "." > sscanf("A string.", cat("%c" $ 10))[]; "A", " ", "s", "t", "r", "i", "n", "g", "." > convert("A string.", list)[]; "A", " ", "s", "t", "r", "i", "n", "g", "."
I’m not sure if this is exactly what you had in mind. Let me know.