Skip to content

Instantly share code, notes, and snippets.

View allison-casey's full-sized avatar
🤗

Allie Jo Casey allison-casey

🤗
  • Firsthand
  • California
View GitHub Profile

Project Management

  • #1778 move from google groups
  • #1900 github actions for stale issues/PRs and package deployment
  • #1738 fancy landing page for Hy
  • #1751 move CI away from Travis
  • #957 add donation option to support hy dev
  • #1618 bring vim-hy up to date

Probably should be closed

  • #817 magically call (global sym) when using setv
@allison-casey
allison-casey / walk.hy
Created November 24, 2020 01:48
iterable unpacking let macro
(defmacro let [bindings &rest body]
"
sets up lexical bindings in its body
Bindings are processed sequentially,
so you can use the result of an earlier binding in a later one.
Basic assignments (e.g. setv, +=) will update the let binding,
if they use the name of a let binding.
@allison-casey
allison-casey / dumb.hy
Created July 19, 2020 18:11
Hy Jedi Completions
;; %%
(import os
jedi
astor
re
[hy.compiler [hy-compile]]
[hy.lex [hy-parse mangle unmangle]]
[hy.cmdline [filtered-hy-exceptions]])
;; %%
(defn sqisp-repr [obj]
(cond
(set? obj) (format ["#{%1}" (joinString (map sqisp-repr (iter-items obj)) ", ")])
(map? obj) (format ["{%1}"
(joinString
(map (fn [x]
(joinString [(sqisp-repr (first x))
(sqisp-repr (second x))]
" "))
(iter-items obj)) ", ")])
;; stdlib
(defglobal odd? [x] (!= (% x 2) 0))
(defglobal even? [x] (= (% x 2) 0))
(defglobal list? [x] (= (typeName x) "ARRAY"))
(defglobal string? [x] (= (typeName x) "STRING"))
(defglobal number? [x] (= (typeName x) "SCALAR"))
(defglobal bool? [x] (= (typeName x) "BOOL"))
(defglobal int? [x] (= (floor x) x))
(defglobal pos? [x] (> x 0))
(defglobal neg? [x] (< x 0))
( hint "hello world" );
private _is_odd =
{
params ["_x"];
((_x % 2) != 0)
};
private _is_even =
{
params ["_x"];
((_x % 2) == 0)
( hint "hello world" );
private _is_odd =
{
params ["_x"];
((_x % 2) != 0)
};
private _is_even =
{
params ["_x"];
((_x % 2) == 0)
(import [pyparsing :as pp])
(with [f (open "config.cpp")]
(setv config (.readlines f)))
(setv colon ":"
open-curly "{"
klass (pp.CaselessKeyword "class")
klass-name ((pp.Word (+ pp.alphanums "_")) "class_name")
base-klass ((pp.Word (+ pp.alphanums "_")) "base_class")
;; EFFECTS
;; effects are the fundamentall building block of the engine. they provide a means of interacting with entities and changing their state. they should be as mini.al as possible, leaving the method of their application to higher order elements.
{:type :constant
:target "%.aim"
:operator :add
:value 5}
{:type :expression
:target "%.mobility"
;; EFFECTS
{:type :constant
:target "%.aim"
:operator :add
:value 5}
{:type :expression
:target "%.mobility"
:operator :add
:expression "%.mobility * 0.2"}