This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- All the scripts that should be loaded. | |
-- Put then in load order | |
local URLs = { | |
"https://gist.githubusercontent.com/ruliana/b48dcbaa1ddd92882e9a3cca36d6777f/raw/819bb7ebbd530a1d94601549fd6ae819ecea1cf4/FIN-item-flow-measurement.lua" | |
} | |
local card = computer.getPCIDevices(findClass("FINInternetCard"))[1] | |
if not card then | |
error("Internet card not found") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------- | |
----- UTILITIES ----- | |
--------------------- | |
-- Utilities to get components from the network | |
function getComponents(className) | |
local compos = component.proxy(component.findComponent(findClass(className))) | |
if #compos == 0 then | |
error(string.format("No component of class \"%s\" found", className)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun apply-templates (node templates) | |
(let (output) | |
;; loop through each template | |
(dolist (template templates output) | |
;; if the current node matches the template | |
(when (matches node (car template)) | |
;; apply the template and stop processing further templates | |
(setq output (apply-template node template)) | |
(return output))) | |
;; if no template matched, process the node's children |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define ((builder builder-param other-builder-param) trivial-param) | |
; ... do stuff | |
something) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (builder builder-param other-builder-param) | |
; ... optionally some initialization code | |
(λ (trivial-param) | |
; ... do stuff | |
something)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def builder(builder_param, other_builder_param): | |
# ... optionally some initialization code | |
def the_actual_function(trivial_param): | |
# ... do stuff | |
return something | |
return the_actual_function | |
# Then later... | |
my_func = builder(x, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require | |
racket/generic | |
(for-syntax racket/syntax | |
racket/function | |
syntax/parse | |
syntax/parse/define)) | |
(provide struct* | |
fields name get set) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang regexp-reader racket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (in-groups keep? seq) | |
(let loop ([rem seq] ;; Remaining elements. | |
[group empty]) ;; Accumulates the sequence until we spit it. | |
(cond [(empty? rem) | |
(if (empty? group) ;; When hit the end condition, check if there | |
empty ;; is something to spit. | |
group)] | |
[(keep? (first rem)) ;; Keep the element? Add to group. | |
(loop (rest rem) (cons (first rem) group))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (in-groups keep? seq) | |
(let loop ([rem seq] ;; Remaining elements. | |
[group empty]) ;; Accumulates the sequence until we spit it. | |
(cond [(empty? rem) | |
(if (empty? group) ;; When hit the end condition, check if there | |
empty-stream ;; is something to spit. | |
group)] | |
[(keep? (first rem)) ;; Keep the element? Add to group. | |
(loop (rest rem) (cons (first rem) group))] |
NewerOlder