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
5
votes
1 answer

Conversion library for S-expressions to DOT

I am looking for a simple script or library to convert an s-expression to dot format, and have not had much luck in Googling for a solution. I came across an old awk script (lisp2dot), however I believe that my expressions may be too complex, as I…
erik
  • 3,810
  • 6
  • 32
  • 63
5
votes
1 answer

Visualize s-expressions in real-time

I want to write Lisp/Scheme/Clojure code like this (map inc (range 0 5)) And have it visualized somewhat like this map -- inc \\ range -- 0 \ -- 5 I want to see the tree change in real-time as I manipulate my…
MRocklin
  • 55,641
  • 23
  • 163
  • 235
5
votes
2 answers

Difference between sexp and list in Emacs?

In Emacs there are commands to move cursor across expressions delimited in parentheses (or any brackets), namely forward-sexp, backward-sexp, forward-list and backward-list. In Lisp and any other code they behave similarly, so i see no difference…
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
4
votes
2 answers

Why do we need `nil`?

I do not see why we need nil [1] when to cons a sequence (so-called proper list) of items. It seems to me we can achieve the same goal by using the so-called improper list (cons-ed pairs without an ending nil) alone. Since Lisps [2] have already…
day
  • 2,292
  • 1
  • 20
  • 23
4
votes
2 answers

How to generate a pairlist with no defaults without using alist?

I'm experimenting with simple manipulation of R code and trying to generate an object equivalent to substitute(function(x) x) I am aware I can do something around these lines as.call(list(as.symbol("function"), as.pairlist(alist(x=)),…
10465355
  • 4,481
  • 2
  • 20
  • 44
4
votes
4 answers

What is an S-Expression

All Lisp developers seem to know what an S-Expression is. But can anybody explain this for non Lisp developers? There is already a Wikipedia entry (https://en.wikipedia.org/wiki/S-expression). But that is not really helpful if you don't want to go…
habrewning
  • 735
  • 3
  • 12
4
votes
1 answer

Extending Rcpp::as for custom classes depending on Rcpp.h

I'm working on an Rcpp sparse matrix class that uses both Rcpp::IntegerVector (row/column pointers) and a templated std::vector. The rationale is that overhead in deep-copying the integer pointer vectors (@i, @p) in extremely large…
zdebruine
  • 3,687
  • 6
  • 31
  • 50
4
votes
1 answer

What does the M-expression list[x;y] do in LISP?

I was reading this paper on LISP by McCarthy (way above my skill set). While defining the evaluation of (LABEL, f, e) here, he used an M-expression (I think it's an M-expression, correct me if I am wrong) list[x;y]. {Actually,…
volf
  • 83
  • 1
  • 10
4
votes
2 answers

Unable to use s-expressions

I'm following Real World OCaml to get started with the language, and, at one point, I am to make use of s-expressions in a module signature. Here's my mli file: open Core.Std (** Configuration type for query handlers *) type config with sexp (**…
Richard-Degenne
  • 2,892
  • 2
  • 26
  • 43
4
votes
3 answers

Pretty-print Lisp using Python

Is there a way to pretty-print Lisp-style code string (in other words, a bunch of balanced parentheses and text within) in Python without re-inventing a wheel?
Max Malysh
  • 29,384
  • 19
  • 111
  • 115
4
votes
1 answer

(Prolog) Parsing Lisp s-expressions Into Prolog Terms

I have written a parser in Prolog that takes a tokenized list and should return an expression where the variable is unified with the value of the evaluated equation: Tokens = ['(', is, v('X',3),'(', +, 1, 2, ')', ')' ] Expr = (3 is 1 + 2) At…
Dirigo
  • 323
  • 1
  • 4
  • 12
4
votes
2 answers

S-expression Tree to Abstract Syntax Tree in OCaml

I'm implementing a symbolic language in OCaml and have been struggling to translate my s-expression tree into an abstract syntax tree. The s-expression tree is (* sexpr.mli *) type atom = | Atom_unit | Atom_int of int | Atom_sym of…
4
votes
1 answer

Org-Mode table to s-expressions

I would like to export from Org-Mode tables to s-expressions. | first | second | thrid | |--------+--------+--------| | value1 | value2 | value3 | | value4 | value5 | value6 | Would turn into: ((:FIRST "value1" :SECOND "value2" :THIRD "value3") …
Wraithan
  • 1,237
  • 2
  • 11
  • 14
4
votes
3 answers

LISP 1.5 How lisp is like a machine language?

I wish that John McCarthy was still alive, but... From LISP 1.5 Programmer's Manual : LISP can interpret and execute programs written in the form of S- expressions. Thus, like machine language, and unlike most other higher level languages, it…
4
votes
2 answers

what is the difference between a syntax and s-expressions

what is the main differences between syntax language and s-expressions language ? does using s-expressions affects compiling time (in the parsing process) or does it bring any advantage to the language ?
Ayoub M.
  • 4,690
  • 10
  • 42
  • 52
1 2
3
9 10