search for: list_length

Displaying 6 results from an estimated 6 matches for "list_length".

Did you mean: _list_length
2018 Feb 11
4
Parallel assignments and goto
...sation with pattern matching as in https://github.com/mailund/pmatch where I can, for example, define a linked list like this: devtools::install_github("mailund/pmatch?) library(pmatch) llist := NIL | CONS(car, cdr : llist) and define a function for computing the length of a list like this: list_length <- function(lst, acc = 0) { force(acc) cases(lst, NIL -> acc, CONS(car, cdr) -> list_length(cdr, acc + 1)) } The `cases` function creates an environment that binds variables in a pattern-description that over-scopes the expression to the right of `->`, so the recurs...
2018 Feb 11
0
Parallel assignments and goto
...://github.com/mailund/pmatch where I can, for example, define a linked list like this: > > devtools::install_github("mailund/pmatch?) > library(pmatch) > llist := NIL | CONS(car, cdr : llist) > > and define a function for computing the length of a list like this: > > list_length <- function(lst, acc = 0) { > force(acc) > cases(lst, > NIL -> acc, > CONS(car, cdr) -> list_length(cdr, acc + 1)) > } > > The `cases` function creates an environment that binds variables in a pattern-description that over-scopes the expression to the...
2018 Feb 26
0
Parallel assignments and goto
...tps://github.com/mailund/pmatch where I can, for example, define a linked list like this: > > devtools::install_github("mailund/pmatch?) > library(pmatch) > llist := NIL | CONS(car, cdr : llist) > > and define a function for computing the length of a list like this: > > list_length <- function(lst, acc = 0) { > force(acc) > cases(lst, > NIL -> acc, > CONS(car, cdr) -> list_length(cdr, acc + 1)) > } > > The `cases` function creates an environment that binds variables in a pattern-description that over-scopes the expression to the right of `->`,...
2018 Feb 14
0
Parallel assignments and goto
...thub.com/mailund/pmatch > where I can, for example, define a linked list like this: > > devtools::install_github("mailund/pmatch?) > library(pmatch) > llist := NIL | CONS(car, cdr : llist) > > and define a function for computing the length of a list like this: > > list_length <- function(lst, acc = 0) { > force(acc) > cases(lst, > NIL -> acc, > CONS(car, cdr) -> list_length(cdr, acc + 1)) } > > The `cases` function creates an environment that binds variables in a pattern- > description that over-scopes the expression to...
2018 Feb 27
2
Parallel assignments and goto
...can, for example, define a linked list like this: > > > > devtools::install_github("mailund/pmatch?) > > library(pmatch) > > llist := NIL | CONS(car, cdr : llist) > > > > and define a function for computing the length of a list like this: > > > > list_length <- function(lst, acc = 0) { > > force(acc) > > cases(lst, > > NIL -> acc, > > CONS(car, cdr) -> list_length(cdr, acc + 1)) > > } > > > > The `cases` function creates an environment that binds variables in a pattern-description that over-scopes the...
2018 Feb 27
0
Parallel assignments and goto
...ike this: > > > > > > devtools::install_github("mailund/pmatch?) > > > library(pmatch) > > > llist := NIL | CONS(car, cdr : llist) > > > > > > and define a function for computing the length of a list like this: > > > > > > list_length <- function(lst, acc = 0) { > > > force(acc) > > > cases(lst, > > > NIL -> acc, > > > CONS(car, cdr) -> list_length(cdr, acc + 1)) > > > } > > > > > > The `cases` function creates an environment that binds variables in a > p...