Skip to content

Instantly share code, notes, and snippets.

class Solution:
def networkDelayTime(self, edges, N, K):
"""
:type times: List[List[int]]
:type N: int
:type K: int
:rtype: int
"""
edges.sort(key=lambda e: e[2])
# print(edges)

the basics

Here is an intro to the basics in leema. The format will show some code, then explain the concepts used in that code. See what you think!

making a palindrome

This is a function that takes a string and returns it as a palindrome.

setup

The setup for leema is still pretty manual, but is only 3 steps.

dependencies

  • C/C++ standard libraries
  • flex
  • nosetests (optional until you want to run tests)
diff --git a/T/prefab.lma b/T/prefab.lma
index ad970e2..efb8d8f 100644
--- a/T/prefab.lma
+++ b/T/prefab.lma
@@ -18,28 +18,28 @@ macro fail(ft, msg) ->
macro refail(f) ->
return f
--

Leema at Recurse Center

the past six weeks

I've spent the past six weeks working on Leema full time at a place called Recurse Center. It's been a great opportunity and I've made a lot of progress.

the next six weeks

@mdg
mdg / curry_syntax.md
Last active September 20, 2018 15:55
rough draft of a blog post to go on leema.org

currying vs. default parameters

I didn't set out to implement currying. I was trying to implement closures but it seemed like it would be easier to implement closures if I added currying first.

But I didn't set out to implement closures either. I originally wanted to implement asynchronous expressions and futures but they too seemed easier to implement if I already had closures.

use Dogma.RuleBuilder
defrule Dogma.Rule.FnParens, [] do
@moduledoc """
A rule that enforces using parens in a fn that takes parens
"""
@fn_pattern ~r/fn(\s*)(\(|->)?/
def test(rule, script) do
script.processed_lines
color
flavor
humor
labor
center
fiber
liter
theater
analyze
defense
color
flavor
humor
labor
center
fiber
liter
theater
analyse
defense
@mdg
mdg / -
Created November 23, 2016 16:34
docker0 Link encap:Ethernet HWaddr 02:42:46:54:e0:ff
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp0s31f6 Link encap:Ethernet HWaddr 54:ee:75:9a:dd:8e
UP BROADCAST MULTICAST MTU:1500 Metric:1