subject

**Language: Erlang** Without using Erlang’s lists module functions, write a function concat/1, whose type is given by the following:
-spec concat(Lists :: [[T]]) -> [T].
The function concat takes a list of lists of elements (of some type T) and returns a list of the elements (of type T) formed by concatenating the inner lists together in order.
The following are examples written using the Erlang testing module. You can use the built-in ++ in your code, or any other helping functions. Run these tests by compiling your file and the
testing file, and then running concat_tests:main().
Example:
% $Id: concat_tests. erl, v 1.3 2015/03/12 13:50:59 leavens Exp leavens $
-module(concat_tests).
-import(testing,[dotests/2,eqTest/3 ]).
-export([main/0, tests/1]).
main() ->
compile:file(concat),
dotests("concat_tests $Revision: 1.3 $", tests(fun concat:concat/1)).
-spec tests(CFun :: fun(([[T]]) -> [T])) -> testing:testCase([atom()]).
tests(CFun) ->
[eqTest(CFun([]), "==", []),
eqTest(CFun([[]]), "==", []),
eqTest(CFun([[fee], [fie], [fo], [fum]]), "==", [fee, fie, fo, fum]),
eqTest(CFun([[], [hmm], [], [okay]]), "==", [hmm, okay]),
eqTest(CFun([[keep], [ancient, lands], [your, storied, pomp], [cries, she]]),
"==", [keep, ancient, lands, your, storied, pomp, cries, she]),
eqTest(CFun([[four, score, nd, seven], [years, ago], [our, ancestors],
[brought, forth, on, this, continent], [a, new, nation]]),
"==", [four, score, nd, seven, years, ago, our, ancestors,
brought, forth, on, this, continent, a, new, nation]),
eqTest(CFun([[[more],[nested]], [[than],[before]]]),
"==", [[more], [nested], [than], [before]])
].

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:10, reycaden
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, aesthetickait
How do you take a green screen out of the video while editing?
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, gabby640
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
image
Computers and Technology, 23.06.2019 16:30, saintsfan2004
How to do this programming flowchart?
Answers: 3
You know the right answer?
**Language: Erlang** Without using Erlang’s lists module functions, write a function concat/1, whos...

Questions in other subjects:

Konu
Mathematics, 17.07.2019 03:10