Another ‘toot that became too long’ post, this time about dynamically vs strictly typed languages. Vapour is a new language that just dropped that has strict typing and transpiles to R (dynamic types) which means developers can write and refactor code with all the benefits of a …
Leap Years with GCD in various languages
I saw this deck via Haskell Weekly Recap which noted an interesting property:
“x is a leap year if and only if gcd(80, x) > gcd(50, x)”
(gcd = ‘greatest common divisor’) which I haven’t fully appreciated the origin of, but wanted to try some implementations. The …
R function call overhead
I’m entirely perplexed by this - I was exploring an idea I saw discussed in a blog post (that will have to wait for now - I’ll come back to it) and found some interesting behaviour I don’t understand.
I managed to boil the issue down to the following: let’s say I have a …
Book review: Data Analysis with AI and R
I published Beyond Spreadsheets with R with Manning Publications partly because they approached me, but a lot because they seem to do a good job of publishing technical books and making them DRM free - if you buy a physical copy you get access to the eBooks to download (pdf, epub, …) and use …
Enums in R
I’m looping back to reading some of Tidy Design Principles since it hasn’t been touched in a while (indicating some stability, at least in the short term). I jumped ahead to a section on enums out of curiosity and pondered on them a bit more - they’re really useful in Rust, maybe …
Fuzzy Grouping
A former colleague got in touch recently with a question about how one might perform the following grouping operation…
Given a set of medical terms that may include typos and variations (as is typically the case for real-world medical data) group “similar” items together in the …
Friends, Romans, Countrymen, lend me your debuggers
This was just going to be a short toot, but it keeps growing so I moved it over to here.
I thought I was about to have the shortest “cheat” solution to an #Exercism problem - Roman Numerals - where we need to convert a number to roman. R already has as.roman() though it returns an object …
Filtering Vectors
I saw a YouTube short demonstrating how to use filter() in Python along the lines of
nums=range(1,30) def is_prime(num): for x in range(2,num): if (num%x) == 0: return False return True primes=list(filter(is_prime, nums)) print(primes) # [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29] and as always, I like …
FizzBuzz without an if
Apparently using an if to solve FizzBuzz is a sign that you’re not a great programmer… Well, that’s how I would have done it :-(
I wanted to see what the map alternative looked like, and I found this python example
print(*map(lambda i: 'Fizz'*(not i%3)+'Buzz'*(not i%5) or i, …
Implicit or Explicit connection object?
I’m wrapping a (stateless, hit-every-time) REST API and my design was challenged with an alternative opinion - which is great! I get to have a more serious think about design and what might work best. I have an internal function which does the actual talking to the server, e.g. .get_from_API() …
R challenge - contour in a matrix
As part of what will hopefully become a larger post, I’m interested in finding an R way to achieve the following: given an n x n matrix of zeroes with a single non-zero element of some value v, fill the surrounding entries such that each other element is at most one less than those surrounding …
ByRow optimizations in Julia
I’m still fairly new to Julia, even though I’ve been trying to learn it for a few years. It’s extremely powerful (fast, expressive, … whatever metric you want to use) but with that comes some complexity.
I saw this post in my feed and it seemed like a great bite-sized chunk …