Skip to content

Commit

Permalink
Update 'Morel: The basic language' and 'Word Count revisited' posts n…
Browse files Browse the repository at this point in the history
…ow that [MOREL-27] has been fixed

See julianhyde/morel#27;
`List_rev` is now `List.rev`, etc.
  • Loading branch information
julianhyde committed May 3, 2020
1 parent ed8b7c0 commit 06c6dc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions blog/_posts/2020-03-03-morel-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ variable called `it`, and prints the value and its type. You can use
```sml
= "morel";
val it = "morel" : string
= String_size it;
= String.size it;
val it = 5 : int
= it + 4;
val it = 9 : int
Expand Down Expand Up @@ -245,9 +245,9 @@ type variables. This means that if `f` has type `'a -> 'b`, for any
types `'a` and `'b`, then `map f` will transform a list of '`a' to a
list of '`b'.

For example, if `f` is the built-in function `String_length` of type
For example, if `f` is the built-in function `String.size` of type
`string -> int`, then `'a` is `string` and `'b` is `int`, and `map
String_length` will convert a `string list` to an `int list`.
String.size` will convert a `string list` to an `int list`.

Notice that we did not declare any types; the type system deduced
everything for us. Type inference is perhaps ML's greatest feature. In
Expand Down Expand Up @@ -463,3 +463,6 @@ If you have comments, please reply on Twitter:
<div data_dnt="true">
{% twitter page.tweet limit=5 hide_media=true %}
</div>

This article
[has been updated](https://github.com/julianhyde/share/commits/master/blog/_posts/2020-03-03-morel-basics.md).
7 changes: 5 additions & 2 deletions blog/_posts/2020-03-31-word-count-revisited.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ fun wordCount lines =
let
fun split0 [] word words = word :: words
| split0 (#" " :: s) word words = split0 s "" (word :: words)
| split0 (c :: s) word words = split0 s (word ^ (String_str c)) words
fun split s = List_rev (split0 (String_explode s) "" [])
| split0 (c :: s) word words = split0 s (word ^ (String.str c)) words
fun split s = List.rev (split0 (String.explode s) "" [])
in
from line in lines,
word in split line
Expand Down Expand Up @@ -446,3 +446,6 @@ If you have comments, please reply on Twitter:
<div data_dnt="true">
{% twitter page.tweet limit=5 hide_media=true %}
</div>

This article
[has been updated](https://github.com/julianhyde/share/commits/master/blog/_posts/2020-03-31-word-count-revisited.md).

0 comments on commit 06c6dc6

Please sign in to comment.