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

How to parse string to list in typed racket

I am working on writing a simple parser in typed Racket, and as part of it, I want to parse string representations of s-expressions to lists as follows: "(+ 1 (/ 2 (inc 0)))" => (list '+ 1 (list '/ 2 (list 'inc 0 ))). Is there an easy way to do…
Someone
  • 800
  • 1
  • 7
  • 25
0
votes
3 answers

Looking for tools on Sexp expressions in Ruby

I am a recent fan of s-exp expressions in Ruby. I discovered Sexpistol parser for instance. Are you using other dedicated tools around them (schemas etc ) ?
JCLL
  • 5,379
  • 5
  • 44
  • 64
0
votes
1 answer

TypeError: 'int' object is not subscriptable while doing s-expression in Python

I am trying to write a basic s-expression calculator in Python using s-expression which can contains add or multiply or both or none or just an integar number. I tried the following snippet: def calc(expr): print(expression[0]) if…
Reactoo
  • 916
  • 2
  • 12
  • 40
0
votes
1 answer

Unbound value "string_of_sexp"

It works quite well in utop with #require "ppx_jane" but I added (preprocess (pps ppx_jane)) in my dune file which looks like this: (library (preprocess (pps ppx_jane)) (name raftml) (modules raft rpc types) (libraries core core_unix …
Murphy
  • 47
  • 7
0
votes
1 answer

How to represent multiple-output logic circuits in tree-based genetic programming

Consider the following digital logic circuit, which has multiple inputs and one output: The logic circuit above can be represented in tree form: This tree representation could then be used in a tree-based genetic programming framework to evolve…
Flux
  • 9,805
  • 5
  • 46
  • 92
0
votes
1 answer

DrRacket: Desurgaring all uses of and, or, not into nested ifs

So I am currently learning how to program and we started with DrRacket. This week the task consists of using pattern matching and working/translating expressions into s-expressions and vice versa. I was able to implement most of the task in a…
user17949498
0
votes
1 answer

Why do these two equivalent expressions in java and lisp have different outcomes?

The expression in lisp is: (* (+ a b) (- a (/ 1 b))) The equivalent expression (I think) in Java is: (a + b) * (a - (1/b)); But when I input the same a and b float values into both, they evaluate differently. Why is that?
0
votes
1 answer

How to make your way through an S-expression tree to satisfy a test case

So I have this S-expression array const condition = [ 'OR', [ 'AND', ['==', '$State', 'Alabama'], ['==', '$Profession', 'Software development'] ], ['==', '$Undefined', ''], [ 'AND', ['==', '$State', 'Texas'] ], [ …
IWI
  • 1,528
  • 4
  • 27
  • 47
0
votes
1 answer

Can Haskell match on S-Expression like match of Racket?

I just started to learn Haskell three days ago, aiming for a interpreter for some custom-ed semantics in Haskell. I have the Racket implementation of the interpreter, the match matching on the S-Expression in Racket is pretty handy. When it comes to…
user618815
0
votes
1 answer

How to convert a list of numbers to separated strings using Lisp?

Given the following code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Copyright (C) 2014 Wojciech Siewierski ;; ;; …
Victor Lopez
  • 110
  • 1
  • 9
0
votes
3 answers

Help parsing S-Expression

I'm trying to make a simple drawing program that reads in translate (rect 10 10 10 10) 50 50. What I'm trying to do is split it so that the 50 50 goes with the translate and the rect keeps all the 10s. This is a PostScript fill. I've heard of hash…
Jr Tim
  • 9
  • 1
0
votes
1 answer

Running s-expressions from File

I have a sexp in a file and i want to read in and then run it in ruby. Whenever I try to run it, it tells me SexpTypeError, exp must be a Sexp, was String: Is there a way to run the Sexp from file? I am using the ruby2ruby gem and ruby_parser…
0
votes
1 answer

What is the name of mathematical object similar to a graph, but with different kind of edges?

While modeling biochemical networks in the cell using Racket, I recognized that I use a certain model for this task. This model resembles a directed graph, with edges pointed not only to vertices but sometimes to other edges. I wonder is there any…
0
votes
1 answer

Parsing and building S-Expressions using Sets and binary search tree

This is pseudo homework (it's extra credit). I've got a BST which is an index of words that point to the lines (stored somewhere else) that contain the words. I need to implement a way to search using s-expressions so I can combine and (&) and or…
Pete
  • 10,651
  • 9
  • 52
  • 74
0
votes
1 answer

How does one fix a parsing error with what seems a valid s-expression in Python?

I had an unexpected error when parsing a (string) s-expression into a nested array/lists representing the AST. The s-expression comes from (SerAPI https://github.com/ejgallego/coq-serapi), but it looks fine to me: sexp = b'(Answer…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323