06-Aug-2023 09:43:07 chrpak_test(): MATLAB/Octave version 9.14.0.2306882 (R2023a) Update 4. Test chrpak(). a_to_i4_test(): a_to_i4() converts Alphabetic character => I 1:26 = A:Z 27:52 = a:z I ==> A ==> I 0 " " 0 3 "C" 3 6 "F" 6 9 "I" 9 12 "L" 12 15 "O" 15 18 "R" 18 21 "U" 21 24 "X" 24 27 "a" 27 30 "d" 30 33 "g" 33 36 "j" 36 39 "m" 39 42 "p" 42 45 "s" 45 48 "v" 48 51 "y" 51 54 " " 0 base_to_i4_test(): base_to_i4() converts an integer in some other base into base 10. BASE, I, I4_TO_BASE(I), BASE_TO_I4(I4_TO_BASE(I)) -1 5 101010101 5 1 5 11111 5 2 21 10101 21 3 -243 -100000 -243 4 16 100 16 8 15 17 15 binary_to_i4_test() binary_to_i4() converts a binary to an integer. I4 ==> BINARY ==> I4 21 10101 21 -32 -100000 -32 2 10 2 128 10000000 128 boolean_to_string_test(): boolean_to_string() creates the string "True" or "False" based on a boolean value. This can be useful when printing boolean results. I isPrime? 1 False 2 True 3 True 4 False 5 True 6 False 7 True 8 False 9 False 10 False ch_cap_test(): ch_cap() uppercases a character. C CH_CAP(C) F F f F 1 1 b B & & ch_is_digit_test(): ch_is_digit() is TRUE if a character represents a digit. C ch_is_digit(C) "0" 1 "1" 1 "2" 1 "3" 1 "4" 1 "5" 1 "6" 1 "7" 1 "8" 1 "9" 1 "X" 0 "?" 0 " " 0 ch_is_isbn_digit_test(): ch_is_isbn_digit() is TRUE if a character represents an ISBN digit. C CH_IS_ISBN_DIGIT(C) "0" 1 "1" 1 "2" 1 "3" 1 "4" 1 "5" 1 "6" 1 "7" 1 "8" 1 "9" 1 "X" 1 "x" 1 "Y" 0 "?" 0 "*" 0 " " 0 ch_low_test(): ch_low() lowercases a character. C CH_LOW(C) F f f f 1 1 b b & & ch_to_digit_test(): ch_to_digit(): character -> decimal digit 1 "0" 0 2 "1" 1 3 "2" 2 4 "3" 3 5 "4" 4 6 "5" 5 7 "6" 6 8 "7" 7 9 "8" 8 10 "9" 9 11 "X" -1 12 "?" -1 13 " " -1 ch_to_rot13_test(): ch_to_rot13() "encodes" characters using ROT13 (and digits using ROT5). A second application of the function returns the original character. CH : ABCDEFGHIJKLMNOPQRSTUVWXYZ ROT13(CH) : NOPQRSTUVWXYZABCDEFGHIJKLM ROT13(ROT13(CH)): ABCDEFGHIJKLMNOPQRSTUVWXYZ CH : CH_TO_ROT13 "encodes" characters using ROT13 ROT13(CH) : PU_GB_EBG68 "rapbqrf" punenpgref hfvat EBG68 ROT13(ROT13(CH)): CH_TO_ROT13 "encodes" characters using ROT13 ch_uniform_test(): ch_uniform() returns a random character in a range. All characters will be between "D" and "W" I A Count 1 A 0 2 B 0 3 C 0 4 D 5141 5 E 5404 6 F 5249 7 G 5288 8 H 5311 9 I 5234 10 J 5309 11 K 5292 12 L 5187 13 M 5214 14 N 5297 15 O 5265 16 P 5289 17 Q 5227 18 R 5310 19 S 5143 20 T 5235 21 U 5328 22 V 5277 23 W 0 24 X 0 25 Y 0 26 Z 0 chvec_lt_test(): chvec_lt() is TRUE if c1 < c2 for character strings c1 and c2. C1 C2 C1 character. -2 "*" -1 -1 "*" -1 0 "0" 0 1 "1" 1 2 "2" 2 3 "3" 3 4 "4" 4 5 "5" 5 6 "6" 6 7 "7" 7 8 "8" 8 9 "9" 9 10 "*" -1 11 "*" -1 digits_decimal_to_r8_test(): digits_decimal_to_r8() converts base 10 digits of a number into a real value; Given decimal digits: 1 2 0 3 4 and "decimal place" p = -2 corresponding value is r8 = 0.012034 Given decimal digits: 9 8 7 6 5 4 3 and "decimal place" p = 3 corresponding value is r8 = 9876.54 Given decimal digits: 3 1 4 1 5 9 2 6 5 and "decimal place" p = 0 corresponding value is r8 = 3.14159 digits_sexagesimal_print_test(): digits_sexagesimal_print() prints a real number as a sexagesimal quantity; Sexagesimal digit vector: 11 12 0 14 15 p = -5: 00.00,00,00,00,11,12,00,14,15 p = -4: 00.00,00,00,11,12,00,14,15 p = -3: 00.00,00,11,12,00,14,15 p = -2: 00.00,11,12,00,14,15 p = -1: 00.11,12,00,14,15 p = 0: 11.12,00,14,15 p = 1: 11,12.00,14,15 p = 2: 11,12,00.14,15 p = 3: 11,12,00,14.15 p = 4: 11,12,00,14,15. p = 5: 11,12,00,14,15,00. digits_sexagesimal_to_r8_test(): digits_sexagesimal_to_r8() converts base 60 digits of a number into a real value; Given sexagesimal digits: 4 37 46 40 and sexagesimal "decimal place" p = 3 corresponding value is r8 = 1e+06 Given sexagesimal digits: 3 8 29 44 0 47 25 and sexagesimal "decimal place" p = 0 corresponding value is r8 = 3.14159 Given sexagesimal digits: 1 24 51 10 7 46 6 4 and sexagesimal "decimal place" p = 0 corresponding value is r8 = 1.41421 chrpak_test046(): hex_to_i4(), hexadecimal->integer. i4_to_hex(), integer->hexadecimal I I4_TO_HEX(I) HEX_TO_I4(I4_TO_HEX(I)) 21 15 21 -32 -20 -32 1776 6F0 1776 hex_digit_to_i4_test(): hex_digit_to_i4() converts hex_digit -> integer Hex -> I4 -> Hex " " 0 "0" "0" 0 "0" "1" 1 "1" "2" 2 "2" "3" 3 "3" "4" 4 "4" "5" 5 "5" "6" 6 "6" "7" 7 "7" "8" 8 "8" "9" 9 "9" "a" 10 "A" "b" 11 "B" "c" 12 "C" "d" 13 "D" "e" 14 "E" "f" 15 "F" "A" 10 "A" "B" 11 "B" "C" 12 "C" "D" 13 "D" "E" 14 "E" "F" 15 "F" "?" -1 "?" i4_length_test(): i4_length() computes an integer's "length". I4 Length 0 1 1 1 -1 2 140 3 -1952 5 123456 6 i4_to_a_test(): i4_to_a() converts I => Alphabetic character 1:26 = A:Z 27:52 = a:z I ==> A ==> I 0 " " 0 3 "C" 3 6 "F" 6 9 "I" 9 12 "L" 12 15 "O" 15 18 "R" 18 21 "U" 21 24 "X" 24 27 "a" 27 30 "d" 30 33 "g" 33 36 "j" 36 39 "m" 39 42 "p" 42 45 "s" 45 48 "v" 48 51 "y" 51 54 " " 0 i4_to_base_test(): i4_to_base() converts an integer base 10 to its representation in another base; BASE, I, I4_TO_BASE(I), BASE_TO_I4(I4_TO_BASE(I)) -1 5 101010101 5 1 5 11111 5 2 21 10101 21 3 -243 -100000 -243 4 16 100 16 8 15 17 15 i4_to_binary_test(): i4_to_binary() converts an integer to binary, I4 ==> BINARY ==> I4 21 10101 21 -32 -100000 -32 2 10 2 128 10000000 128 i4_to_binhex_test(): i4_to_binhex() converts I => BINHEX character The BINHEX alphabet "!"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTVWXYZ[`abcdefhijklmpqr" i4_to_hex_digit_test(): i4_to_hex_digit() converts integer -> hex digit I4 Hex I4 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 A 10 11 B 11 12 C 12 13 D 13 14 E 14 15 F 15 i4_to_isbn_digit_test(): i4_to_isbn_digit() converts digits 0 to 10 to an ISBN digit. 0 48 1 49 2 50 3 51 4 52 5 53 6 54 7 55 8 56 9 57 10 88 i4_to_month_abb_test(): i4_to_month_abb() returns an abbreviated month name. I4 Month abb 0 "?" 1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul" 8 "Aug" 9 "Sep" 10 "Oct" 11 "Nov" 12 "Dec" 13 "?" i4_to_month_name_test(): i4_to_month_name() returns a month name. I4 Month name 0 "?" 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" 13 "?" i4_to_nunary_test(): i4_to_nunary() converts an integer to negative unary. I4 NUNARY -5 1010101010 0 0 7 1010101010101 i4_to_oct_test(): i4_to_oct() converts integer -> octal I4 OCT I4 21 25 21 -32 -40 -32 1776 3360 1776 i4_to_unary_test(): i4_to_unary() converts an integer to unary. I4 UNARY -5 -11111 0 0 7 1111111 i4_to_uudecode_test(): i4_to_uudecode() converts I => UUDECODE character The UUDECODE alphabet "`!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_" i4_to_xxdecode_test(): i4_to_xxdecode() converts I => XXDECODE character The XXDECODE alphabet "+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" i4vec_print_test(): i4vec_print() prints an I4VEC The I4VEC: 1: 91 2: 92 3: 93 4: 94 isbn_digit_to_i4_test(): isbn_digit_to_i4() converts an ISBN digit to an I4 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 X 10 oct_to_i4_test(): oct_to_i4() converts octal -> integer. I4 OCT I4 21 25 21 -32 -40 -32 1776 3360 1776 r8_to_digits_decimal_test(): r8_to_digits_decimal() converts a real number to its representation in base 10; 8 decimal digits of 0.01 1 1 0.01 2 0 0.001 3 0 0.0001 4 0 1e-05 5 0 1e-06 6 0 1e-07 7 0 1e-08 8 0 1e-09 8 decimal digits of 1.41421 1 1 1 2 4 0.1 3 1 0.01 4 4 0.001 5 2 0.0001 6 1 1e-05 7 3 1e-06 8 5 1e-07 8 decimal digits of 3.14159 1 3 1 2 1 0.1 3 4 0.01 4 1 0.001 5 5 0.0001 6 9 1e-05 7 2 1e-06 8 6 1e-07 8 decimal digits of 1e+06 1 1 1e+06 2 0 100000 3 0 10000 4 0 1000 5 0 100 6 0 10 7 0 1 8 0 0.1 r8_to_digits_sexagesimal_test(): r8_to_digits_sexagesimal() converts a real number to its representation in base 60; 8 sexagesimal digits of 0.01 1 36 0.000277778 2 0 4.62963e-06 3 0 7.71605e-08 4 0 1.28601e-09 5 0 2.14335e-11 6 0 3.57225e-13 7 0 5.95374e-15 8 0 9.9229e-17 8 sexagesimal digits of 1.41421 1 1 1 2 24 0.0166667 3 51 0.000277778 4 10 4.62963e-06 5 7 7.71605e-08 6 46 1.28601e-09 7 6 2.14335e-11 8 4 3.57225e-13 8 sexagesimal digits of 3.14159 1 3 1 2 8 0.0166667 3 29 0.000277778 4 44 4.62963e-06 5 0 7.71605e-08 6 47 1.28601e-09 7 25 2.14335e-11 8 53 3.57225e-13 8 sexagesimal digits of 1e+06 1 4 216000 2 37 3600 3 46 60 4 40 1 5 0 0.0166667 6 0 0.000277778 7 0 4.62963e-06 8 0 7.71605e-08 s_begin_test(): s_begin() checks the beginning of a string for a substring, ignoring case and spaces. S1 S2 S_BEGIN(S1,S2) Bob BOB 1 B o b bo b 1 Bob BOBBY 1 Bobo Bobb 0 Bob 0 cubic meter cubic meter 1 s_behead_substring_test(): s_behead_substring() removes an initial substring from a string, if it occurs. ------String-------- -----SUB------------ ---Beheaded---- HELLO World! HELLO World! 12345678901234567890 12345 678901234567890 0.314159E+01 314 0.314159E+01 !@#$%a^&A(){}[]\\|<>? !@#$%a^&A(){}[]\\|<>? s_digits_count_test(): s_digits_count() counts the digits in a string. We count 7 digits in "34E94-70.6" We count 0 digits in "Not a one!" We count 3 digits in "%8*k >>>> # SEVEN-0.3" s_eqi_test(): s_eqi() compares two strings for equality, ignoring case and trailing blanks. A B S_EQI(A,B) 0 = FALSE, 1 = TRUE "NixoN" "niXon" 1 "animal" "CRACKER" 0 "Yes" "y" 0 "ALPHA" "zeta" 0 "NIX on" "Nixon" 0 "blank" "blank " 1 s_escape_tex_test(): s_escape_tex() "protects" characters in a string that might otherwise be interpreted as TeX escape characters. Original string: "The file A_B.TXT is {I think__so} of size 2^8 or C\B." Modified string: "The file A\_B.TXT is \{I think\_\_so\} of size 2\^8 or C\\B." Original string: "file_name: Fat T." Modified string: "file\_name: Fat T." s_inc_c_test(): s_inc_c() can "increment" the characters in a string. Starting string: "Tax" Incremented forms: "Tay" "Taz" "Tba" "Tbb" "Tbc" Starting string: "aB34c* 8zY" Incremented forms: "aB34c* 8zZ" "aB34d* 8aA" "aB34d* 8aB" "aB34d* 8aC" "aB34d* 8aD" s_quote_test(): s_quote() quotes a string S1 with a mark MARK. ----S1---- ---MARK--- ----S2---- Hi, Bob! " "Hi, Bob!" De Loop LoopDeLoop s_replace_ch_test(): s_replace_ch() replaces one character by another; C1 C2 Original String Modified String n t No pennies now. No petties tow. s_replace_ch_by_s_test(): s_replace_ch_by_s() replaces one character by a string; C S_REP Original String Modified String n 1\1 No pennies now. No pe1\11\1ies 1\1ow. s_s_subanagram_test(): s_s_subanagram() is TRUE if S2 is a "subanagram" of S1. "Get a priest!" "stripe" 1 "Get a priest!" "pastor" 0 "Get a priest!" "a sip " 1 "Get a priest!" "tag! " 0 s_scrabble_points_test(): s_scrabble_points() returns the value of a string as a Scrabble word. I ----S------- Value 1 January 17 2 February 16 3 March 12 4 April 7 5 May 8 6 June 11 7 July 14 8 August 7 9 September 15 10 October 11 11 November 15 12 December 15 s_sort_a_test(): s_sort_a() ascending sorts a string. -------String------- -------Sorted------- "HELLO World !! ! " " !!!EHLLOWdlor" "12345678901234567890" "00112233445566778899" "Abc Def Ghi Jkl Mno " " ADGJMbcefhiklno" "AbleBakerCharlieDelt" "ABCDaabeeeehiklllrrt" "What? You have seen?" " ??WYaaeeehhnostuv" s_substitute_test(): s_substitute() substitutes characters in a string. Old chars = "gao" New chars = "Jen" Old string = "Galapagos" New string = "GelepeJns" s_to_caesar_test(): s_to_caesar() applies a Caesar Shift cipher to a string. S2 = S_TO_CAESAR ( S1, K ), varying K. K ---------------S1---------------- ---------------S2---------------- -5 "A man, a plan, a canal: Panama!" "A hai, a kgai, a aaiag: Kaiaha!" -4 "A man, a plan, a canal: Panama!" "A iaj, a lhaj, a aajah: Lajaia!" -3 "A man, a plan, a canal: Panama!" "A jak, a miak, a aakai: Makaja!" -2 "A man, a plan, a canal: Panama!" "A kal, a njal, a aalaj: Nalaka!" -1 "A man, a plan, a canal: Panama!" "A lam, a okam, a bamak: Oamala!" 0 "A man, a plan, a canal: Panama!" "A man, a plan, a canal: Panama!" 1 "A man, a plan, a canal: Panama!" "B nbo, b qmbo, b dbobm: Qbobnb!" 2 "A man, a plan, a canal: Panama!" "C ocp, c rncp, c ecpcn: Rcpcoc!" 3 "A man, a plan, a canal: Panama!" "D pdq, d sodq, d fdqdo: Sdqdpd!" 4 "A man, a plan, a canal: Panama!" "E qer, e tper, e gerep: Tereqe!" 5 "A man, a plan, a canal: Panama!" "F rfs, f uqfs, f hfsfq: Ufsfrf!" S2 = S_TO_CAESAR ( S1, K ). S3 = S_TO_CAESAR ( S2, -K ) K ------------S1------------ ------------S2------------ ------------S3------------ -5 "The key is under the mat" "Oca fat dn piaam oca hao" "Thf kfy is unffr thf mft" -4 "The key is under the mat" "Pda gau eo qjaan pda iap" "The key is uneer the met" -3 "The key is under the mat" "Qeb hbv fp rkabo qeb jaq" "The key is under the mdt" -2 "The key is under the mat" "Rfc icw gq slbcp rfc kar" "The key is under the mct" -1 "The key is under the mat" "Sgd jdx hr tmcdq sgd las" "The key is under the mbt" 0 "The key is under the mat" "The key is under the mat" "The key is under the mat" 1 "The key is under the mat" "Uif lfz jt voefs uif nbu" "The key is under the mat" 2 "The key is under the mat" "Vjg mga ku wpfgt vjg ocv" "The kea is under the mat" 3 "The key is under the mat" "Wkh nhb lv xqghu wkh pdw" "The kea is under the mat" 4 "The key is under the mat" "Xli oic mw yrhiv xli qex" "The kea is under the mat" 5 "The key is under the mat" "Ymj pjd nx zsijw ymj rfy" "The kea is under the mat" s_to_digits_test(): s_to_digits(): string -> digit vector Test string: "34E94-70.6" Extracted 5 digits: 1: 3 2: 4 3: 9 4: 4 5: 7 Test string: "34E94-70.6" Extracted 7 digits: 1: 3 2: 4 3: 9 4: 4 5: 7 6: 0 7: 6 s_to_format_test(): s_to_format() converts string -> FORTRAN format RcW.M; --------String------ R c W M a80 1 a 80 0 f8.4 1 f 8 4 3g14.6 3 g 14 6 i12 1 i 12 0 12l1 12 l 1 0 (10o11) 10 o 11 0 ( 5 z 11.7 ) 5 z 11 7 s_to_isbn_digits_test(): s_to_isbn_digits() converts string -> ISBN digit vector Test string: "34E9X-70.6" Extracted 5 digits: 1: 3 2: 4 3: 9 4: 10 5: 7 Test string: "34E9X-70.6" Extracted 7 digits: 1: 3 2: 4 3: 9 4: 10 5: 7 6: 0 7: 6 s_to_l4_test(): s_to_l4() reads logical data from a string. S L4 "0 " 0 "F " 0 "f " 0 "1 " 1 "T " 1 "t " 1 " 0 " 0 " 1 0 " 1 " 01 " 0 " Talse" 1 s_to_rot13_test(): s_to_rot13() applies the ROT13 cipher to a string. S2 = S_TO_ROT13 ( S1 ). -------------------S1------------------- -------------------S2------------------- "abcdefghijklmnopqrstuvwxyz" "nopqrstuvwxyzabcdefghijklm" "Cher" "Pure" "James Thurston Howell III" "Wnzrf Guhefgba Ubjryy VVV" "The bill is $1,205,837.49 so pay now!" "Gur ovyy vf $6,750,382.94 fb cnl abj!" S2 = S_TO_ROT13 ( S1 ). S3 = S_TO_ROT13 ( S2 ). -------------------S1------------------- -------------------S3------------------- "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" "Cher" "Cher" "James Thurston Howell III" "James Thurston Howell III" "The bill is $1,205,837.49 so pay now!" "The bill is $1,205,837.49 so pay now!" s_word_count_test(): s_word_count() counts the words in a string STRING Words "? " 1 "A man, a plan, a canal - Panama!" 8 " justone!word,-@#$ " 1 "How about a day in the park? " 7 s_word_extract_first_test(): s_word_extract_first() extracts the first word from a string. Our input string is: "Just an incontrovertible sample of text!" "Just" "an" "incontrovertible" "sample" "of" "text!" Reached the last word. state_id_from_index_test(): state_id_from_index() returns the state ID (postal code) for a given index from 1 to 50. First 5 ID's: 1 "AL" 2 "AK" 3 "AZ" 4 "AR" 5 "CA" state_name_from_index_test(): state_name_from_index() returns the state name for a given index from 1 to 50. First 5 names: 1 "Alabama" 2 "Alaska" 3 "Arizona" 4 "Arkansas" 5 "California" vector_to_element_test(): vector_to_element() converts a MATLAB expression from vector to elementwise form. vector form: "x^2*sin(x)" elementwise: "x .^ 2 .* sin(x)" vector form: "x.^2.*sin(x)" elementwise: "x.^2.*sin(x)" vector form: "1. + 2./x*exp(x^2)" elementwise: "1. + 2./x .* exp(x .^ 2)" vector form: "4^2+2*sin(pi/2)" elementwise: "4 .^ 2+2 .* sin(pi ./ 2)" chrpak_test(): Normal end of execution. 06-Aug-2023 09:43:07