Questions tagged [gensym]

Gensym is an online service for Real-Time Management of Mission Critical Systems

(a) A gensym is a generated symbol in lisp dialects, used to avoid accidental capture when writing macros.

(b) Gensym is an online service for real-Time Management of Mission Critical Systems Create and run process and production control applications with the world's leading expert system development platform.

10 questions
15
votes
3 answers

Coordinating auto-gensym in nested syntax-quotes in Clojure

In Clojure, you need to use gensym to create symbols for internal use in your macros to keep them hygienic. However, sometimes you need to use the same symbol in nested syntax-quotes. For example, if I want to bind a value to a symbol with let and…
Idan Arye
  • 12,402
  • 5
  • 49
  • 68
13
votes
1 answer

How to break conversation data into pairs of (Context , Response)

I'm using Gensim Doc2Vec model, trying to cluster portions of a customer support conversations. My goal is to give the support team an auto response suggestions. Figure 1: shows a sample conversations where the user question is answered in the next…
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
12
votes
2 answers

Uninterned symbols symbols

There is something I can't understand about Common lisp. Assume I'm writing a macro similar to this: (defmacro test-macro () (let ((result (gensym))) `(let ((,result 1)) (print (incf ,result))))) Than I can do >…
JustAnotherCurious
  • 2,208
  • 15
  • 32
8
votes
2 answers

How to test a clojure macro that uses gensyms?

I want to test a macro that uses gensyms. For example, if I want to test this: (defmacro m1 [x f] `(let [x# ~x] (~f x#))) I can use macro-expansion... (macroexpand-1 '(m1 2 inc)) ...to get... (clojure.core/let [x__3289__auto__ 2] (inc…
David J.
  • 31,569
  • 22
  • 122
  • 174
6
votes
5 answers

What does gensym do in Lisp?

contextualization: I've been doing a university project in which I have to write a parser for regular expressions and build the corresponding epsilon-NFA. I have to do this in Prolog and Lisp. I don't know if questions like this are allowed, if not…
zeta.exe
  • 61
  • 1
  • 5
6
votes
2 answers

Why does this Lisp macro as a whole work, even though each piece doesn't work?

I'm reading/working through Practical Common Lisp. I'm on the chapter about building a test framework in Lisp. I have the function "test-+" implemented as below, and it works: (defun test-+ () (check (= (+ 1 2) 3) (= (+ 5 6) 11) (= (+…
Charlie Flowers
  • 17,338
  • 10
  • 71
  • 88
2
votes
1 answer

how to apply gensym to each specific variable

I want to write a macro (my-dotimes [x init end] & body) that computes the value of body for x going from init to end-1 in increments of 1. Here you again have to make sure to avoid the "variable capture problem". It should work like this: user=>…
Xiufen Xu
  • 531
  • 1
  • 3
  • 19
0
votes
0 answers

G2 Gensym post from C#

I am trying to past a message to system G2, but I get error, No overload for method 'PostMessage' takes 2 arguments. Can you please help, thks private void PostMsgBtn_Click(object sender, EventArgs e) { object[] C1_ob = new object[1]; …
Praw
  • 1
  • 1
0
votes
1 answer

Why is next not gensymed?

Here x is gensymned because some expression passed to and can have x in it and to avoid that conflict. Then why is next not gensymed? Couldn't next lead to variable capture? (defmacro and ([] true) ([x] x) ([x & next] `(let [and# ~x] …
John Doe
  • 2,225
  • 6
  • 16
  • 44
0
votes
2 answers

How do I write this macro in clojure?

I've got this function: (defn handler [request] (case (request :uri) "/" (home request) "/good" (good request) "/evil" (evil request) "/neutral" (neutral request) (status-response 404 (str "

404 Not Found: " (:uri request)…

John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110