[erlang-questions] An erlang exercise which confused me

カカキ heturing@REDACTED
Mon Sep 24 09:26:03 CEST 2018


I am reading programming erlang (2nd Ed.) and get a little confused by the
exercise 16-6.

Here is the question

Twits are exactly 140 bytes long. Write a random-access twit storage module
called twit_store.erl that exports the following: init(K) allocates space
for K twits. store(N, Buf) stores twit number N(1,...K) with data Buf (a
140-byte binary) in the store. fetch(N) fetches the data for twit number N.

I am confused by the meaning of init(K). I try to use function
file:allocate but always get a result of {error, einval}. Could anyone help
me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180924/2d705627/attachment.htm>


More information about the erlang-questions mailing list