-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
108 lines (84 loc) · 5.99 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<title>my tech blog</title>
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28316373-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head
<body>
<header>
<div class="header">
<div class="logo" href="#">my tech blog
<span><nowrap>To iterate is human, to recurse divine</nowrap></span>
</div>
</div>
</header>
<div class="main">
<div class="sidebar">
<h1>elsewhere</h1>
<ul>
<li><a href="https://plus.google.com/u/0/116672115299154240194"><img src="images/google.png"></a></li>
<li><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/MemberProfile" data-id="http://www.linkedin.com/in/stefanalfbo" data-format="hover" data-text="Stefan Alfbo" data-related="false"></script></li>
<li>
<a href="https://twitter.com/stefanalfbo" class="twitter-follow-button" data-show-count="false">Follow @stefanalfbo</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</li>
<li><a href="https://github.com/stealf"><img src="images/github.png"></a></li>
</ul>
<h1>tags</h1>
beginning blog memo memoization F# functional pipeline operator
</div>
<div class="content">
<div class="post">
<h1>pipeline operator in F#</h1>
<div class="date">Monday, Mars 27, 2012</div>
<p>First time I came in contact with a pipeline operator was on the linux command shell (bash) several years ago. It amazed me how powerful this little operator could be to compose more complicated commands.</p>
<p>The great thing is that there is a similar powerful operator available in F#, and you will see it appear often in F# code.</p>
<p>The pipeline operator looks like this in F#, |>, there are actually several other variants of the operator which we will see later. Here are some simple examples how to use it:</p>
<script src="https://gist.github.com/2218950.js?file=Simple%20examples%20of%20pipeline%20operator"></script>
<p>As I mentioned earlier there are other variants that we can use depending on our situation. We have, <|, ||>, <|| and more. Hopefully the examples below will clarify how they work.</p>
<script src="https://gist.github.com/2219058.js?file=more%20simple%20pipeline%20operator%20examples.fs"></script>
<p>F# is open source and the code is hosted on github, so we can dig into the code and see how these operators are implemented.</p>
<p>Here is the url to the repository: <a href="https://github.com/fsharp/fsharp">github.com/fsharp/fsharp</a>. The file we are interested in is the prim-types.fs and is located in <b>fsharp/src/fsharp/FSharp.Core</b> directory, look around line 3492 to find the things we want.</p>
<script src="https://gist.github.com/2219106.js?file=extract%20from%20fsharp%20repository.fs"></script>
<p>Yes, it's concise, beautiful and simple, as always in F# ;-)</p>
<div class="tags">tags: F#, pipeline operator</div>
</div>
<div class="post">
<h1>memoization</h1>
<div class="date">Monday, Mars 5, 2012</div>
<p>This technique feels like it's mandatory to describe if you are writing a book about functional programming. That might be because it emphasize the side effect free property of languages in this genre. However this technique can be used in a imperative language as well.</p>
<p>So what is memoization? I would sum it up as an optimization technique to cache calculations done by a function in run-time.</p>
<p>The beauty with side effect free functions is that with the same input we will always receive the same result no matter when/where we call it. This make it very easy to store the calculated result into a dictionary and use it at a later time.</p>
<p>Lets show the memoization in action with a simple example in F#:</p>
<script src="https://gist.github.com/1944805.js?file=memoization_simple.fs"></script>
<p>This memoization function works fine in this simple case, however we would get in trouble if it were a recursive function that we wanted to memoize. The solution for a recursive function might be good material for a part two post of the memoization function :-)</p>
<p>If you would like to find out more about this technique I recommend you to search the net on these keywords: memoization, memo and memoised function.</p>
<p>Finally the memoization technique where "invented" by Professor Donald Michie, ["'Memo' functions: and machine learning", Donald Michie, Nature, 218, 19-22, 1968]. Here is his site: <a href='http://www.aiai.ed.ac.uk/~dm/dm.html'>Donald Michie Home Page</a></p>
<div class="tags">tags: memo, memoization, F#, functional</div>
</div>
<div class="post">
<h1>time to start my blog</h1>
<div class="date">Thursday, January 12, 2012</div>
<p>Better sooner than later, I guess.</p>
<p>I have decided to drop wordpress as my choice of blog engine and going to create my own from scratch instead. This first version will be a simple static page, but will hopefully evolve to something better in the future. The source code will of course be available on github.</p>
<p>My initial goal with this blog is at least to publish a post each month, but we will see.</p>
<p>So... lets start blogging.</p>
<div class="tags">tags: beginning, blog</div>
</div>
</div>
</div>
<footer>
</footer>
</body>
</html>