>> From: Maple Group
| >> From: "Nathan Sokalski"
|
| 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?
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 21 Jun 2001 13:35:35 -0700
From: Allan Wittkopf
To:
Subject: Character Sequences
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]
Sincerely,
Allan Wittkopf
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 22 Jun 2001 03:24:52 +0200
From: Helmut Kahovec
To:
Subject: Character Sequences
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"
With kind regards,
Helmut
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 21 Jun 2001 19:27:09 -0700 (PDT)
From: Robert Israel
To:
Subject: Character Sequences
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.
> seq(c,c="a".."d");
or
> $"a".."d";
Robert Israel
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 22 Jun 2001 08:25:24 -0400
To:
From: "Gerald A. Edgar"
Subject: Character Sequences
It's not entirely clear what you want...
Perhaps something like this?
> str1 := "";
> for x from "a" to "z" by 2 do str1 := cat(str1,x) od:
> str1;
str1 := ""
"acegikmoqsuwy"
> str1[3..7];
"egikm"
Or perhaps this?
> cat("a" .. "j");
a, b, c, d, e, f, g, h, i, j
--
G. A. Edgar http://www.math.ohio-state.edu/~edgar/
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Stanley J Houghton
Date: Fri, 22 Jun 2001 14:54:37 +0100
To:
Subject: Character Sequences
You can always use convert with the bytes option (which converts
strings to ascii codes and back).
> convert([i$i=65..68],bytes); # gives "ABCD"
or for a sequence
> seq(convert([i],bytes),i=65..68); # gives "A","B","C","D"
If you wish you can also convert the strings to names (convert with
name option).
Hope it helps
Stan
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 22 Jun 2001 10:09:47 -0700
From: "Joe Riel (home)"
To:
Subject: Character Sequences
> alphabet := "abcdefghijklmnopqrstuvwxyz":
> seq(alphabet[i],i=3..5);
"c", "d", "e"
> cat(%);
"cde"
Joe Riel
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 22 Jun 2001 19:29:40 -0400 (EDT)
From: Carl DeVore
To:
Subject: Character Sequences
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.
|