Questions tagged [s-expression]

S-expressions are a notation for nested list or tree-structured data, popularized by the Lisp programming language.

In computing, s-expressions, sexprs or sexps (for "symbolic expression") are a notation for nested list (tree-structured) data, invented for and popularized by the programming language which uses them for source code as well as data.

Source: Wikipedia

138 questions
7
votes
2 answers

Is out there anything that is for s-expressions what XPATH is for XML?

I am looking for a common-lisp impl if possible. (Also, I dont want to convert sexp to XML and use xpath on the result.)
Paralife
  • 6,116
  • 8
  • 38
  • 64
7
votes
3 answers

Do any lisps have a s-expression as their head, e.g. ((f 2) 3 4)? If not, why?

Do any lisps support nested s-expression on their head? For example ((f 2) 3 4) for which (f 2) presumably evaluates to a function/macro to apply on 3 4. Is it possible to have a lisp supporting such a thing? Or are there technical limitations…
spacingissue
  • 497
  • 2
  • 12
7
votes
3 answers

Common lisp: is there a less painful way to input math expressions?

I enjoy common lisp, but sometimes it is really painful to input simple math expressions like a(8b^2+1)+4bc(4b^2+1) (Sure I can convert this, but it is kind of slow, I write (+ () ()) first, and then in each bracket I put (* () ())...) I'm…
h__
  • 865
  • 1
  • 11
  • 19
6
votes
2 answers

Is there an Awk- or Lisp-like programming language that can process a stream of s-expressions?

I have been creating some PCB footprints in KiCad recently, which are stored in s-expression files with data that looks like this: (fp_text user %R (at 0 5.08) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) (fp_line (start -27.04996…
Caleb Reister
  • 263
  • 1
  • 2
  • 9
6
votes
2 answers

What is the meaning of the 'send' keyword in Ruby's AST?

I am trying to learn the Ruby lexer and parser (whitequark parser) to know more about the procedure to further generate machine code from a Ruby script. On parsing the following Ruby code string. def add(a, b) return a + b end puts add 1, 2 It…
pravj
  • 300
  • 3
  • 10
6
votes
2 answers

XML, S-Expressions, and overlapping scope... What's it called?

I was reading XML is not S-Expressions. XML scoping is kind of strict, as are S-expressions. And in every programming language I've seen, you can't have the following: BOLD BOTH ITALIC == BOLD BOTH ITALIC It's not even expressible…
Mr. White
  • 61
  • 2
6
votes
2 answers

nested dictionary output from pyparsing

I'm using pyparsing to parse an expression of the form: "and(or(eq(x,1), eq(x,2)), eq(y,3))" My test code looks like this: from pyparsing import Word, alphanums, Literal, Forward, Suppress, ZeroOrMore, CaselessLiteral, Group field =…
Horned Owl
  • 139
  • 2
  • 9
6
votes
1 answer

running embedded R in C

I have written up a piece of C code which declares a square matrix of size 4x4. Then it samples from a sampling function called rgig in package GeneralizedHyperbolic in R. It inverses the matrix using a gsl library from gnu and spits out the result.…
user1971988
  • 845
  • 7
  • 22
6
votes
1 answer

S-expression for directed acyclic graph?

as we know tree structure could be represented in S-expressions. For example (5 (4 (11 (7 () ()) (2 () ()) ) ()) (8 (13 () ()) (4 () (1 () ()) ) ) ) But is it possible to use S-expression for a graph (esp. DAG)? e.g. My second question is what…
est
  • 11,429
  • 14
  • 70
  • 118
6
votes
1 answer

How can sexplib be used with functor types like Map?

Sexplib's syntax extension makes serialization and deserialization of arbitrary user-defined data structures easy in OCaml. It is generally done by adding a with sexp annotation to the end of a type definition: type a = A of int | B of float with…
jrk
  • 2,896
  • 1
  • 22
  • 35
5
votes
2 answers

Search and replace on variable name within S-Expression (lexical scope)?

Using emacs with Paredit enabled. How can I search through a LISP (Clojure) S-expression and rename a variable? I'd like to do it within the current S-expression instead of globally.
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
5
votes
4 answers

Correct way of parsing S-expressions in OOP

I am looking for a way to implement an S-expression reader (to be used later on with both an Scheme interpreter and a compiler), but I've been asking myself how (if at all) I should write an AST for it. I've been reading SICP, and this is quite…
ivanmp
  • 519
  • 1
  • 5
  • 13
5
votes
2 answers

How to return a named VECSXP when writing R extensions

Recently I had a bug and when fixing it I wondered if it is possible to return a VECSXP (i.e. an R list type), where the elements are named. This c++ code: SEXP do_bla() { int prtCnt = 0; SEXP a = PROTECT(allocMatrix(REALSXP, 5, 5)); …
user1972382
5
votes
1 answer

Using 'with sexp' on a type generates "Warning 4: this pattern-matching is fragile"

I've just started using the with sexp syntax extension (described here and here) on my custom types. However, I've noticed that when I do, I get the following warning about my type: Warning 4: this pattern-matching is fragile. It will remain…
5
votes
3 answers

How to evaluate an expression in prefix notation

I am trying to evaluate a list that represents an expression in prefix notation. Here is an example of such a list: [+, [sin, 3], [- 10 5]] What is the best way to evaluate the value of the list
ad126
  • 53
  • 1
  • 1
  • 4
1
2
3
9 10