Baby steps with a nif

Sunday, 14th August, 2011

simple_nif is an erlang NIF which takes a list of integers and returns a record, called params, containing the sum, the mean, and the quartiles of the input list:

1> simple:get_params([1,2,3,4,5,6,7]).
{params,28,4.0,{2.0,4.0,6.0}}

The main point of the exercise was the C interface between erlang and the C functions. The file simple_nif.c shows how to parse the input list from erlang into a C array, and how to assemble the results into an erlang tuple to return.

More details in the README.

I am releasing the code under the ISC license.

References

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: