0

enter image description here

this doesn't look like java/python/c/..etc

its from a book about algorithm/data structures

after a few searches i felt like this is called functional programming, but still this ADD/ZERO/ISZERO/for_loop_syntax is different in it,

so, what is this thing?, what do i call this type of writings?

& where do i run it? [if its a programming language]

is it wrong, if i write ADD(x,y) as SUM(x,y)?

ANDuser
  • 71
  • 8
  • 1
    What is the book? – Paul Hankin Oct 03 '22 at 09:26
  • That seems like just some sort of pseudo code, not an actual programming language. The book should introduce that at some point. The first part ("declare") declares a bunch of functions; the second part ("for") is _not_ a for-loop but defines the values/evaluation rules for all those function "for" different parameters. That bit is indeed written in the style of some functional languages. (In fact I would not rule out that it _is_ an actual programming language) – tobias_k Oct 03 '22 at 09:31
  • i don't remember its name, its about data structures and algorithms, it also had a structure/function for ARRAY `CREATE()` creates an empty array. `RETRIEVE()` retrieve value from an array at the given index. `STORE()` to add a new value to the given index on given array – ANDuser Oct 03 '22 at 09:35

1 Answers1

2

The code is a formal definition of a Polynomial as computer data structure.

Source is the Book Fundamentals of Data Structures by Ellis Horowitz and Sartaj Sahni. The language being used is called SPARKS.

Introduction to the defintion from the book (page 47; Chapter 2: Arrays):
The first step is to consider how to define polynomials as a computer structure. For a mathematician a polynomial is a sum of terms where each term has the form ax^e; x is the variable, a is the coefficient and e is the exponent. However this is not an appropriate definition for our purposes. When defining a data object one must decide what functions will be available, what their input is, what their output is and exactly what it is that they do. A complete specification of the data structure polynomial is now given.

Related question.

Axel Kemper
  • 10,544
  • 2
  • 31
  • 54