你做得很好,但还有一点点。首先,您需要将 (/@) FromDigits 映射到每个二进制序列上,代表一个字符。第二次将(@@)StringJoin 应用到FromCharacterCode 的结果中,得到原始拼接的String。Apply 将任何表达式的 Head 替换为应用于其参数的新函数。
一般来说,减少挫败感:-) 试着让问题休息一下,然后再回来解决问题,或者像你一样寻求帮助。这是一种优雅的语言,会逐渐变得本能。
In[9]:= string1 =
"The quick brown fox jumped over the lazy white dog.";
In[10]:= ToCharacterCode@string1
Out[10]= {84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, \
119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 101, 100, 32, \
111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, \
119, 104, 105, 116, 101, 32, 100, 111, 103, 46}
In[11]:= IntegerDigits[%10, 2, 8]
Out[11]= {{0, 1, 0, 1, 0, 1, 0, 0}, {0, 1, 1, 0, 1, 0, 0, 0}, {0, 1,
1, 0, 0, 1, 0, 1}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 0, 0, 0,
1}, {0, 1, 1, 1, 0, 1, 0, 1}, {0, 1, 1, 0, 1, 0, 0, 1}, {0, 1, 1, 0,
0, 0, 1, 1}, {0, 1, 1, 0, 1, 0, 1, 1}, {0, 0, 1, 0, 0, 0, 0,
0}, {0, 1, 1, 0, 0, 0, 1, 0}, {0, 1, 1, 1, 0, 0, 1, 0}, {0, 1, 1, 0,
1, 1, 1, 1}, {0, 1, 1, 1, 0, 1, 1, 1}, {0, 1, 1, 0, 1, 1, 1,
0}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 1, 1, 0}, {0, 1, 1, 0,
1, 1, 1, 1}, {0, 1, 1, 1, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0,
0}, {0, 1, 1, 0, 1, 0, 1, 0}, {0, 1, 1, 1, 0, 1, 0, 1}, {0, 1, 1, 0,
1, 1, 0, 1}, {0, 1, 1, 1, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 1, 0,
1}, {0, 1, 1, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0,
1, 1, 1, 1}, {0, 1, 1, 1, 0, 1, 1, 0}, {0, 1, 1, 0, 0, 1, 0,
1}, {0, 1, 1, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 1,
0, 1, 0, 0}, {0, 1, 1, 0, 1, 0, 0, 0}, {0, 1, 1, 0, 0, 1, 0,
1}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 1, 1, 0, 0}, {0, 1, 1, 0,
0, 0, 0, 1}, {0, 1, 1, 1, 1, 0, 1, 0}, {0, 1, 1, 1, 1, 0, 0,
1}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 0, 1, 1, 1}, {0, 1, 1, 0,
1, 0, 0, 0}, {0, 1, 1, 0, 1, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 0,
0}, {0, 1, 1, 0, 0, 1, 0, 1}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0,
0, 1, 0, 0}, {0, 1, 1, 0, 1, 1, 1, 1}, {0, 1, 1, 0, 0, 1, 1,
1}, {0, 0, 1, 0, 1, 1, 1, 0}}
In[14]:= FromDigits[#, 2] & /@ %11
Out[14]= {84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, \
119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 101, 100, 32, \
111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, \
119, 104, 105, 116, 101, 32, 100, 111, 103, 46}
In[15]:= FromCharacterCode@# & /@ %14
Out[15]= {"T", "h", "e", " ", "q", "u", "i", "c", "k", " ", "b", "r", \
"o", "w", "n", " ", "f", "o", "x", " ", "j", "u", "m", "p", "e", "d", \
" ", "o", "v", "e", "r", " ", "t", "h", "e", " ", "l", "a", "z", "y", \
" ", "w", "h", "i", "t", "e", " ", "d", "o", "g", "."}
In[16]:= StringJoin @@ %15
Out[16]= "The quick brown fox jumped over the lazy white dog."