This blog has relocated to https://coolbutuseless.github.ioand associated packages are now hosted at https://github.com/coolbutuseless.

29 April 2018

General features

## Generating Executable ASCII art

``````C=strsplit('851+-. ','')[[1]]
i=jpeg::readJPEG(system.file('img/Rlogo.jpg',package='jpeg'))[c(T,F),,2]
i[]=C[findInterval(i,quantile(i,p=seq(0,1,,length(C))))]
cat(apply(i,1,paste,collapse=''),sep='\n')``````
``````                  --        -  --   -    ++++++++++++++++++      --  --     -   -  - -+
-    - +  -- ++++155555555555555555555555555555551+++   -+-    +--  +
- +- -…``````

## Changing the default arguments to a function

Say I don’t like the default arguments of a particular function. What can I do about it?

## Solving the 8 queens problem

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other.

## Finding a length n needle in a haystack

What’s a good way to find the location of a `needle` in a `haystack`?

## Parsing data part 4: Parsing the Easter Bunny with minilexer

In this post, as an example of using `minilexer`, I’ll parse the stanford bunny 3D object into an R data structure and display it.

## Parsing data part 3: parsing chess game files

In this post, as an example of using `minilexer`, I’ll parse chess games into an R data frame.

## Parsing data part 1. The `minilexer` package - A Simple Lexer in R

I need to read some foreign data formats into R data structures for manipulation. If the data was csv or yaml or json then I’d just use a package that someone else had written to read in the data. In my case, the data format doesn’t have its own package, so I need to write some parsing code from scratch.

## Assert condition over a code block

Most (all?) testing packages in R are built around the idea of testing a value at a particular moment in time e.g. “Check that `a == 2` right now”.