Sponsored links: Algebra eBooks
 

Related

cint

Run Example
(%i1)debugmode(true);
(%o1)                                true
(%i2) characters:charlist("Ala");
(%o2)                              [A, l, a]
(%i3) for i:1 while i <
 slength("Ala") do( cint(characters[i]) );
(%o3)                                done
(%i4) 
Run Example
le:"Без труда - не вытащишь и рыбку из пруда!";
(%o1)              ??? ????? - ?? ???????? ? ????? ?? ?????!
(%i2) cost:7;
(%o2)                                  7
(%i3) zakod(cost,le):=(    k:[],    con:cost,    ind_from:32,    ind_till:126,    count_char:ind_till-ind_from+1,    ind_from_ru:192,    ind_till_ru:255,    count_char_ru:ind_till_ru-ind_from_ru+1,    alpha:count_char_ru+count_char,    minus(x):=mod(x+alpha-con,alpha),    plus(x):=mod(x+con,alpha),    num_2_my_alph(x):=if x<
95 then ascii(x+ind_from) else ascii(x-1+ind_from_ru-ind_till+ind_from),    my_alph_2_num(x):=if x<
=126 then (x-ind_from) else(x-ind_from_ru+ind_till-ind_from+1),    l:charlist(le),    for i in l do(        j:cint(i),            k:endcons(j,k)),    g:map(my_alph_2_num,k),    g:map(plus,g),    h:map(num_2_my_alph,g),    simplode(h)          );
(%o3) zakod(cost, le) := (k : [], con : cost, ind_from : 32, ind_till : 126, 
count_char : ind_till - ind_from + 1, ind_from_ru : 192, ind_till_ru : 255, 
count_char_ru : ind_till_ru - ind_from_ru + 1, 
alpha : count_char_ru + count_char, minus(x) := mod(x + alpha - con, alpha), 
plus(x) := mod(x + con, alpha), num_2_my_alph(x) := 
if x < 95 then ascii(x + ind_from) else ascii(x - 1 + ind_from_ru - ind_till
 + ind_from), my_alph_2_num(x) := if x <= 126 then x - ind_from
 else x - ind_from_ru + ind_till - ind_from + 1, l : charlist(le), 
for i in l do (j : cint(i), k : endcons(j, k)), g : map(my_alph_2_num, k), 
g : map(plus, g), h : map(num_2_my_alph, g), simplode(h))
(%i4) ff:zakod(cost,le);
(%o4)              FFF'FFFFF'4'FF'FFFFFFFF'F'FFFFF'FF'FFFFF(
(%i5) ff;
(%o5)              FFF'FFFFF'4'FF'FFFFFFFF'F'FFFFF'FF'FFFFF(
(%i6) raskod(cost,ff):=(    k:[],    ind_from:32,    ind_till:126,    count_char:ind_till-ind_from+1,    ind_from_ru:192,    ind_till_ru:255,    count_char_ru:ind_till_ru-ind_from_ru+1,    alpha:count_char_ru+count_char,    con:alpha-con,    minus(x):=mod(x+alpha-con,alpha),    plus(x):=mod(x+con,alpha),    num_2_my_alph(x):=if x<
95 then ascii(x+ind_from) else ascii(x-1+ind_from_ru-ind_till+ind_from),    my_alph_2_num(x):=if x<
=126 then (x-ind_from) else(x-ind_from_ru+ind_till-ind_from+1),    l:charlist(ff),    for i in l do(        j:cint(i),            k:endcons(j,k)),    g:map(my_alph_2_num,k),    g:map(plus,g),    h:map(num_2_my_alph,g),    simplode(h)          );
(%o6) raskod(cost, ff) := (k : [], ind_from : 32, ind_till : 126, 
count_char : ind_till - ind_from + 1, ind_from_ru : 192, ind_till_ru : 255, 
count_char_ru : ind_till_ru - ind_from_ru + 1, 
alpha : count_char_ru + count_char, con : alpha - con, 
minus(x) := mod(x + alpha - con, alpha), plus(x) := mod(x + con, alpha), 
num_2_my_alph(x) := if x < 95 then ascii(x + ind_from)
 else ascii(x - 1 + ind_from_ru - ind_till + ind_from), 
my_alph_2_num(x) := if x <= 126 then x - ind_from
 else x - ind_from_ru + ind_till - ind_from + 1, l : charlist(ff), 
for i in l do (j : cint(i), k : endcons(j, k)), g : map(my_alph_2_num, k), 
g : map(plus, g), h : map(num_2_my_alph, g), simplode(h))
(%i7) raskod(7,ff);
(%o7)              ??? ????? - ?? ???????? ? ????? ?? ?????!
(%i8) 
Run Example
debugmode(true);
(%o1)                                true
(%i2) tekst:"ALA";
(%o2)                                 ALA
(%i3) code:[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p];
(%o3)          [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p]
(%i4) characters:charlist(tekst);
(%o4)                              [A, L, A]
(%i5) out:make_array(any,slength(tekst));
(%o5)                      {Array:  #(NIL NIL NIL)}
(%i6) for i:1 while i <
= slength(tekst) do( out[i-1]:code[cint(characters[i])-64]);
(%o6)                                done
(%i7) listarray(out);
(%o7)                              [a, l, a]
(%i8) 

Related Help

Help for Cint