《Erlang 程序设计》练习答案 -- 第三章 基本概念

本文详细介绍了在ErlangShell中使用行编辑命令进行文本操作,并通过实例展示了如何使用元组和列表表示数据结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

% (1).快速浏览 3.13 节,然后测试并记忆这些行编辑命令Erlang shell 中输入
Ctrl + A  行首
Ctrl + D  删除当前字符
Ctrl + E  行尾
Ctrl + F或右箭头  向前的字符(类似跨越一个单词)
Ctrl + B或左箭头  向后的字符
Ctrl + P或上箭头  前一行
Ctrl + N或下箭头  下一行
Ctrl + T  调换最近两个字符的位置
Ctrl + Tab  尝试扩展当前模块或函数的名称(补全)

% (2).在 shell 里输入 help() 命令。你将会看到一长串命令。
% 可以试一试其中一些命令。 

1> help().
** shell internal commands **
b()        -- display all variable bindings
e(N)       -- repeat the expression in query <N>
f()        -- forget all variable bindings
f(X)       -- forget the binding of variable X
h()        -- history
history(N) -- set how many previous commands to keep
results(N) -- set how many previous command results to keep
catch_exception(B) -- how exceptions are handled
v(N)       -- use the value of query <N>
rd(R,D)    -- define a record
rf()       -- remove all record information
rf(R)      -- remove record information about R
rl()       -- display all record information
rl(R)      -- display record information about R
rp(Term)   -- display Term using the shell's record information
rr(File)   -- read record information from File (wildcards allowed)
rr(F,R)    -- read selected record information from file(s)
rr(F,R,O)  -- read selected record information with options
** commands in module c **
bt(Pid)    -- stack backtrace for a process
c(File)    -- compile and load code in <File>
cd(Dir)    -- change working directory
flush()    -- flush any messages sent to the shell
help()     -- help info
i()        -- information about the system
ni()       -- information about the networked system
i(X,Y,Z)   -- information about pid <X,Y,Z>
l(Module)  -- load or reload module
lc([File]) -- compile a list of Erlang modules
ls()       -- list files in the current directory
ls(Dir)    -- list files in directory <Dir>
m()        -- which modules are loaded
m(Mod)     -- information about module <Mod>
memory()   -- memory allocation information
memory(T)  -- memory allocation information of type <T>
nc(File)   -- compile and load code in <File> on all nodes
nl(Module) -- load module on all nodes
pid(X,Y,Z) -- convert X,Y,Z to a Pid
pwd()      -- print working directory
q()        -- quit - shorthand for init:stop()
regs()     -- information about registered processes
nregs()    -- information about all registered processes
uptime()   -- print node uptime
xm(M)      -- cross reference check a module
y(File)    -- generate a Yecc parser
** commands in module i (interpreter interface) **
ih()       -- print help for the i module

% (3).试着用一个元祖来表示一座房子,
% 再用一个贩子列表来表示一条街道。
% 请确保你能向这些结构中加入数据结构或从中取出数据。

1> BigHouse = {bigHouse, piano, cat, dog}.
{bigHouse,piano,cat,dog}
2> SmallHouse = {smallHouse, tortoise}.
{smallHouse,tortoise}
3> Street = {street, BigHouse, SmallHouse}.
{street,{bigHouse,piano,cat,dog},{smallHouse,tortoise}}
4> {street, B, S} = Street. 
{street,{bigHouse,piano,cat,dog},{smallHouse,tortoise}}
5> B.
{bigHouse,piano,cat,dog}
6> S.
{smallHouse,tortoise}
7> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏天的技术博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值