function fib(x: int): int = (
let cache = {} in
let fibc x = if x<=1 then x else (
if x not in cache then
cache[x] = fibc(x-1) + fibc(x-2);
cache[x]
) in fibc(x)
);;
for x in range(10) do print(fib(x))
let primes: list<int> = [];;
for x in range(2,500)
if not primes.any(fn p = x % p == 0)
do primes.append(x);;
print(primes)
import "stdio.h";;
import "stdlib.h";;
printf("%d %d %d\n":char*,5,3,2);;
fprintf(stderr,"%d %d %d\n":char*,2,3,5);;
exit(0)
{% for x in range(99,0,-1) %}
<p>{{ x }} bottles of beer on the wall.</p>
{% end %}
<p>99 bottles of beer on the wall.</p>
<p>98 bottles of beer on the wall.</p>
<p>97 bottles of beer on the wall.</p>
<p>96 bottles of beer on the wall.</p>
<p>95 bottles of beer on the wall.</p>
<p>94 bottles of beer on the wall.</p>
<p>93 bottles of beer on the wall.</p>
<p>92 bottles of beer on the wall.</p>
<p>91 bottles of beer on the wall.</p>
<p>90 bottles of beer on the wall.</p>
<p>89 bottles of beer on the wall.</p>
<p>88 bottles of beer on the wall.</p>
<p>87 bottles of beer on the wall.</p>
<p>86 bottles of beer on the wall.</p>
<p>85 bottles of beer on the wall.</p>
<p>84 bottles of beer on the wall.</p>
<p>83 bottles of beer on the wall.</p>
<p>82 bottles of beer on the wall.</p>
<p>81 bottles of beer on the wall.</p>
<p>80 bottles of beer on the wall.</p>
<p>79 bottles of beer on the wall.</p>
<p>78 bottles of beer on the wall.</p>
<p>77 bottles of beer on the wall.</p>
<p>76 bottles of beer on the wall.</p>
<p>75 bottles of beer on the wall.</p>
<p>74 bottles of beer on the wall.</p>
<p>73 bottles of beer on the wall.</p>
<p>72 bottles of beer on the wall.</p>
<p>71 bottles of beer on the wall.</p>
<p>70 bottles of beer on the wall.</p>
<p>69 bottles of beer on the wall.</p>
<p>68 bottles of beer on the wall.</p>
<p>67 bottles of beer on the wall.</p>
<p>66 bottles of beer on the wall.</p>
<p>65 bottles of beer on the wall.</p>
<p>64 bottles of beer on the wall.</p>
<p>63 bottles of beer on the wall.</p>
<p>62 bottles of beer on the wall.</p>
<p>61 bottles of beer on the wall.</p>
<p>60 bottles of beer on the wall.</p>
<p>59 bottles of beer on the wall.</p>
<p>58 bottles of beer on the wall.</p>
<p>57 bottles of beer on the wall.</p>
<p>56 bottles of beer on the wall.</p>
<p>55 bottles of beer on the wall.</p>
<p>54 bottles of beer on the wall.</p>
<p>53 bottles of beer on the wall.</p>
<p>52 bottles of beer on the wall.</p>
<p>51 bottles of beer on the wall.</p>
<p>50 bottles of beer on the wall.</p>
<p>49 bottles of beer on the wall.</p>
<p>48 bottles of beer on the wall.</p>
<p>47 bottles of beer on the wall.</p>
<p>46 bottles of beer on the wall.</p>
<p>45 bottles of beer on the wall.</p>
<p>44 bottles of beer on the wall.</p>
<p>43 bottles of beer on the wall.</p>
<p>42 bottles of beer on the wall.</p>
<p>41 bottles of beer on the wall.</p>
<p>40 bottles of beer on the wall.</p>
<p>39 bottles of beer on the wall.</p>
<p>38 bottles of beer on the wall.</p>
<p>37 bottles of beer on the wall.</p>
<p>36 bottles of beer on the wall.</p>
<p>35 bottles of beer on the wall.</p>
<p>34 bottles of beer on the wall.</p>
<p>33 bottles of beer on the wall.</p>
<p>32 bottles of beer on the wall.</p>
<p>31 bottles of beer on the wall.</p>
<p>30 bottles of beer on the wall.</p>
<p>29 bottles of beer on the wall.</p>
<p>28 bottles of beer on the wall.</p>
<p>27 bottles of beer on the wall.</p>
<p>26 bottles of beer on the wall.</p>
<p>25 bottles of beer on the wall.</p>
<p>24 bottles of beer on the wall.</p>
<p>23 bottles of beer on the wall.</p>
<p>22 bottles of beer on the wall.</p>
<p>21 bottles of beer on the wall.</p>
<p>20 bottles of beer on the wall.</p>
<p>19 bottles of beer on the wall.</p>
<p>18 bottles of beer on the wall.</p>
<p>17 bottles of beer on the wall.</p>
<p>16 bottles of beer on the wall.</p>
<p>15 bottles of beer on the wall.</p>
<p>14 bottles of beer on the wall.</p>
<p>13 bottles of beer on the wall.</p>
<p>12 bottles of beer on the wall.</p>
<p>11 bottles of beer on the wall.</p>
<p>10 bottles of beer on the wall.</p>
<p>9 bottles of beer on the wall.</p>
<p>8 bottles of beer on the wall.</p>
<p>7 bottles of beer on the wall.</p>
<p>6 bottles of beer on the wall.</p>
<p>5 bottles of beer on the wall.</p>
<p>4 bottles of beer on the wall.</p>
<p>3 bottles of beer on the wall.</p>
<p>2 bottles of beer on the wall.</p>
<p>1 bottles of beer on the wall.</p>
type c3tuple<'a,'b,'c> =
struct { $"0": 'a, $"1": 'b, $"2": 'c };;
function c3tuple(a: 'a, b: 'b, c: 'c):
c3tuple<'a,'b,'c> = new {
$"0" = a,
$"1" = b,
$"2" = c
};;
c3tuple(1,'a',false)
With deferred computation, lambdas, closures, and recursive let bindings, Luck brings functional programming to C99.
Luck syntax and semantics are heavily influenced by Haskell and ML. You don't need to be a scholar to understand Luck, but you will feel welcome here if you are.
Luck has all the common control flow operators and some advanced options as well.
Code written in Luck is terse yet readable. Luck can compete with the best when it comes to powerful one-liners.
Let's face it, there is a lot of code written in C. All languages have to make the choice to either ignore the underlying platform that they run on, or do the work to compile together.
We have done the work.
C and Luck work together.
Luck supports a unique plugin system for language extensions. Libraries can extend the syntax and semantics of the language to fit their needs.
While this does not entirely replace the benefits of dynamic evaluation, it does cover some use cases while still remaining a statically compiled language.
Luck supports parameters on functions and types. This means that you can create generic code that generates multiple implementations of a similar data-structure or function.
Luck is built on the principles of Don't Repeat Yourself and brings this mentality to the systems programming level.