ITKeyword,专注技术干货聚合推荐

注册 | 登录

Erlang 笔试题 1

Genesislive 分享于 2014-03-28

推荐:Erlang 笔试题 2

原创文章,转载请注明: 转载自http://blog.csdn.net/genesislive 本文链接地址: Erlang 笔试题 2 以下试题不分顺序: 1、求hd(tl(tl([1,2,3,4,5,6])))的值。(

2020腾讯云8月秒杀活动,优惠非常大!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1040

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
地址https://www.aliyun.com/minisite/goods

原创文章,转载请注明: 转载自http://blog.csdn.net/genesislive
本文链接地址: Erlang 笔试题 1


1、写一个函数,功能如下:

    0 返回 white

    1 返回 green

    2 返回 blue

   其他 返回 yellow

   分别用function clause, case clause, if clause 实现

 

color1(0) ->
    white;
color1(1) ->
    green;
color1(2) ->
    blue;
color1(_) ->
    yellow.

color2(C) ->
    case C of
	0 -> white;
	1 -> green;
	2 -> blue;
	_ -> yellow
    end.

color3(C) ->
    if
	C =:= 0 ->
	    white;
	C =:= 1 ->
	    green;
	C =:= 2 ->
	    blue;
	true ->
	    yellow
    end.


2、尾递归实现 1+2+3+……+100

sum(Stop, Stop, _Step, Acc) ->
    Stop + Acc;
sum(Start, Stop, Step, Acc) ->
    sum(Start + Step, Stop, Step, Acc + Start).


推荐:华为笔试题

1.程序实现目标: 输入一个字符串,将其各个字符对应的ASCII值加5后,输出结果。     程序要求:该字符串只包含小写字母,若其值加5后的字符值大于'z',将其转换

3、Erlang VM 有哪些原因可能会crashdump

  • "<A>: Cannot allocate <N> bytes of memory (of type "<T>")." - The system has run out of memory. <A> is the allocator that failed to allocate memory, <N> is the number of bytes that <A> tried to allocate, and <T> is the memory block type that the memory was needed for. The most common case is that a process stores huge amounts of data. In this case <T> is most often heap, old_heap,heap_frag, or binary. For more information on allocators see erts_alloc(3).
  • "<A>: Cannot reallocate <N> bytes of memory (of type "<T>")." - Same as above with the exception that memory was being reallocated instead of being allocated when the system ran out of memory.
  • "Unexpected op code N" - Error in compiled code, beam file damaged or error in the compiler.
  • "Module Name undefined" | "Function Name undefined" | "No function Name:Name/1" | "No function Name:start/2" - The kernel/stdlib applications are damaged or the start script is damaged.
  • "Driver_select called with too large file descriptor N" - The number of file descriptors for sockets exceed 1024 (Unix only). The limit on file-descriptors in some Unix flavors can be set to over 1024, but only 1024 sockets/pipes can be used simultaneously by Erlang (due to limitations in the Unix select call). The number of open regular files is not affected by this.
  • "Received SIGUSR1" - The SIGUSR1 signal was sent to the Erlang machine (Unix only).
  • "Kernel pid terminated (Who) (Exit-reason)" - The kernel supervisor has detected a failure, usually that theapplication_controller has shut down (Who = application_controller, Why = shutdown). The application controller may have shut down for a number of reasons, the most usual being that the node name of the distributed Erlang node is already in use. A complete supervisor tree "crash" (i.e., the top supervisors have exited) will give about the same result. This message comes from the Erlang code and not from the virtual machine itself. It is always due to some kind of failure in an application, either within OTP or a "user-written" one. Looking at the error log for your application is probably the first step to take.
  • "Init terminating in do_boot ()" - The primitive Erlang boot sequence was terminated, most probably because the boot script has errors or cannot be read. This is usually a configuration error - the system may have been started with a faulty -boot parameter or with a boot script from the wrong version of OTP.
  • "Could not start kernel pid (Who) ()" - One of the kernel processes could not start. This is probably due to faulty arguments (like errors in a -config argument) or faulty configuration files. Check that all files are in their correct location and that the configuration files (if any) are not damaged. Usually there are also messages written to the controlling terminal and/or the error log explaining what's wrong.

 详见:http://www.erlang.org/doc/apps/erts/crash_dump.html

 

 

 

 

 

 

 

 

 

 

 

推荐:Erlang服务端开发(无需Erlang基础)笔试题

某游戏公司Erlang服务端开发(无需Erlang基础)笔试题,面向C/C++程序员 一、用你熟悉的语言解决下面的问题。 1、反转输出字符串,并移除其中的空格。 2、快速的

原创文章,转载请注明: 转载自http://blog.csdn.net/genesislive 本文链接地址: Erlang 笔试题 1 1、写一个函数,功能如下:     0 返回 white     1 返回 green     2 返回 blue    其他 返回

相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。