Skip to content

Commit

Permalink
preparing for new release...
Browse files Browse the repository at this point in the history
  • Loading branch information
mailund committed Dec 20, 2018
1 parent 2901dff commit 0a39878
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
7 changes: 6 additions & 1 deletion NEWS.md
@@ -1,3 +1,8 @@
# pmatch 0.1.5

* Compatibility with rlang 0.3.0
* Removed `cases` function (use `case_func` instead, it is much faster).

# pmatch 0.1.4

* New constructor code. This gives an substantial speedup when generating objects.
Expand All @@ -11,7 +16,7 @@
# pmatch 0.1.3

* Formula syntax in cases as an alternative: cases(f(x), foo ~ bar, baz ~ qux).
This is easier to get to static code checkes such as lintr and through the
This is easier to get to static code checks such as lintr and through the
byte compiler that can complain about "assignments" to literals.
* bind[x,y,z] <- 1:3 syntax for binding variables.
* transformation function transform_cases_function for modifying a function
Expand Down
2 changes: 1 addition & 1 deletion R/constructors.R
Expand Up @@ -103,7 +103,7 @@ process_constructor_function <- function(constructor, data_type_name, env) {
process_constructor_constant <- function(constructor, data_type_name, env) {
constructor_name <- rlang::as_string(constructor)
constructor_object <- structure(
NA, # FIXME: should this be list() ?
NA,
constructor_constant = constructor_name,
class = data_type_name
)
Expand Down
24 changes: 3 additions & 21 deletions cran-comments.md
@@ -1,35 +1,17 @@



# Update to 0.1.5

* New constructor code. This gives an substantial speedup when generating objects.
* Added `case_func` as a much faster replacement for using the `cases` function.
* Removed `cases` (now that the faster `case_func` provides the same functionality).
* Suggests `ggraph` and `tidygraph` for vignettes
* Fixed a rewrite bug when using qualified names.
* Uses `foolbox` for a safer rewrite function.
* Compatibility with rlang 0.3.0.
* Removed `cases` function (`case_func` and `case_trfunc` replace it).

## Test environments

* local OS X (Mojave) install, R 3.5.1
* ubuntu 14.04 (on travis-ci), R 3.3, 3.4, 3.5
* win-builder (devel)
* win-builder (devel and release)
* RHub:

- Windows Server 2008 R2 SP1, R-devel, 32/64 bit
- Windows Server 2008 R2 SP1, R-release, 32/64 bit
- CentOS 6, stock R from EPEL
- Ubuntu Linux 16.04 LTS, R-release, GCC
- Fedora Linux, R-devel, clang, gfortran
- Fedora Linux, R-devel, GCC
- Debian Linux, R-release, GCC
- macOS 10.11 El Capitan, R-release (experimental)

On Windows and Fedora, I get a Pandoc warning because
it cannot find the README badges. Other than that, the
checks pass.

## R CMD check results

0 errors | 0 warnings | 0 notes
Expand Down
23 changes: 9 additions & 14 deletions man/case_trfunc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vignettes/getting-started-with-pmatch-.Rmd
Expand Up @@ -104,7 +104,7 @@ To define a linked list type we want to specify what the basic instances look li
linked_list := NIL | CONS(car, cdr : linked_list)
```

Here, I have used `car` for the head of a list and `cdr` for the tail. These are traditional names inherited from the [lisp programming language that in turn inherited them from IBM 704](https://en.wikipedia.org/wiki/CAR_and_CDR). I have chosen these names so we do not class with the R functions `head` and `tail`. This expression defines the type `linked_list`, specify that we can create objects of the type using one of the two constructores `NIL` or `CONS()`, where the former takes no arguments and the second two, of which the second argument must be another linked list.
Here, I have used `car` for the head of a list and `cdr` for the tail. These are traditional names inherited from the [lisp programming language that in turn inherited them from IBM 704](https://en.wikipedia.org/wiki/CAR_and_CDR). I have chosen these names so we do not class with the R functions `head` and `tail`. This expression defines the type `linked_list`, specify that we can create objects of the type using one of the two constructors `NIL` or `CONS()`, where the former takes no arguments and the second two, of which the second argument must be another linked list.

We can create `a_list` using these constructors like this:

Expand All @@ -124,7 +124,7 @@ list_length <- case_func(
list_length(a_list)
```

When we pattern-match like this, we also bind variables. In the `CONS(car, cdr)` pattern we didn't have to name the variables `car` and `cdr` just because we called them in the constructor. In the pattern matching they are just variables and they get set to the corresponding values in the structor of `the_list`. This is why we can use `cdr` in the expression we evaluate when we match the pattern—`cdr` will be bound to the tail of the list.
When we pattern-match like this, we also bind variables. In the `CONS(car, cdr)` pattern we didn't have to name the variables `car` and `cdr` just because we called them in the constructor. In the pattern matching they are just variables and they get set to the corresponding values in the structure of `the_list`. This is why we can use `cdr` in the expression we evaluate when we match the pattern—`cdr` will be bound to the tail of the list.

We can also see this in another example where we sum all the elements in a list:

Expand Down

0 comments on commit 0a39878

Please sign in to comment.