I am fairly new to Hylang and I am trying to get the last two code snippets here to work. No matter what I do I get the error that with_gensyms is not defined. I am running hy version 0.27.0, which matches the version of the docs. Below is my sample…
I have the following conftest.py for a pytest plugin for hy, adapted from the official hy conftest, but AssertionErros are not diffed for files beginning with test-, only test_, even when using -vv on the command line.
import os
from pathlib import…
How to translate this Clojure code to Hy, so it prints 2?
It doesn't need to be like Clojure, i just want to hide + and replace it with - in local environment.
(defmacro q [expr]
`(let ~'[+ (fn [x y] (- x y))]
~expr))
(print (q (+ 3 1)))
In…
I have ubuntu 22.04 and hy 0.25
I tried hy-mode, i failed.
I installed doom emacs, but i got this
I also tried to install hy 0.20.0 and i failed again i got this.
If anyone has auto-complete for hy, if possible to send what i should do, hy-mode or…
Is it possible to type-hint variables and return values of functions in Hy language?
# in python we can do this
def some_func() -> str:
return "Hello World"
I just started learning Hy (my first attempt at a Lisp dialect). I have a function that returns a tuple of 2 values, and I don't know how to receive it:
(defn function [] #("Hello" "World"))
; I don't know how to initialize two variables here
(setv…
When trying to require the following macro in another file, the raise seems to be triggering immediately:
(defmacro assert [a [b True] [message None]]
`(unless (= ~a ~b) (raise (AssertionError (or ~message ~a)))))
This results in an…
In the following code, given that hy seem to give a NameError when not explicitly requiring a macro's dependent macros, how do I require a macro in the same file in another macro?
(defmacro with-cwd [#* body] `(do ~@body))
(defmacro let-cwd [vars #*…
How do I require all functions in a hy module in an __init__.py? I tried to use a similar model as in the hyrule __init__.py, but am getting the following error:
Traceback (most recent call last):
File "", line 1, in
File…
In the following directory structure:
.
├── a
│ ├── 1
│ ├── 2
│ ├── 3
│ └── 4
├── b
│ ├── 5
│ ├── 6
│ ├── 7
│ └── 8
├── c
├── d
└── test.hy
The following code prints the wrong path:
(eval-and-compile (import os) (import pathlib…
What's the difference between using (map exec ~body) versus (for [node ~body] node) in the following code?
(defmacro with-cwd [dir #* body]
`(let [ cwd (.cwd Path) ]
(try (.chdir os ~dir)
;; Should I use…
What is the Hy equivalent of Python's a if condition else b?
I'm trying to convert something like this
return (quicksort(under) if under else []) + same + (quicksort(over) if over else [])
to Hy. It avoids calling quicksort() if the list is empty.…