[erlang-questions] Does Erlang pure functional programming language?

Ulf Wiger ulf@REDACTED
Fri Jan 20 21:14:42 CET 2012


There are domain-specific languages that are entirely pure.

One nice example is Cryptol (http://www.cryptol.net, a DSL written in Haskell):

An example from (http://hcss-cps.org/events/erkok.pdf):


encrypt128 : ([4][32],[4][4][8]) -> [4][4][8];
encrypt128 (initialKey, plainText) = cipherText where { 
   roundKeys = [ initialKey ] # [| nextKey (round, prev) 
                                                    || round <- [1..10] 
                                                    || prev <- roundKeys 
                                                    |]; 
   initialState = first(roundKeys) ^ plainText; 
   rounds = [ initialState ] # [| nextState (prev, roundKey, round) 
                                               || round <- [1..10] 
                                               || prev <- rounds 
                                               || roundKey <- drop (1, roundKeys) 
                                               |]; 
   cipherText = last(rounds); 
}

BR,
Ulf W

On 20 Jan 2012, at 16:58, Max Lapshin wrote:

> I can't imagine language, which is built only from pure functions.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120120/096d3228/attachment.htm>


More information about the erlang-questions mailing list