Wordless

From Esolang
Jump to: navigation, search

Wordless is a high-level language created by User:DominoPivot, in which identifiers cannot contain word characters.

Syntax

Identifiers

User-defined variable or function identifier must obey the following rules:

  • Identifiers CANNOT contain letters (from a to z or A to Z), digits (from 0 to 9) or whitespace, except for the first character which MAY be a digit.
  • Identifiers CANNOT consist solely of one digit.

This can be represented by the regular expression \d?[^0-9a-zA-Z\s]+

Therefore, the following identifiers are invalid:

  • user_name
  • database
  • dotProduct

But the following are valid substitutes:

  • 👤🏷️
  • δ_
  • .

Note that while valid, identifiers that use Leet are discouraged. Prefer 🐘 over 3Ļé¶ɧ@ɴ̩Ṱ.

Numbers

There is only one numeric type, decimal. A potential implementation could use DEC64, but determining the exact representation used isn't part of the scope of this article.

Number literals begin with one or more digits, optionally followed by a decimal point and one or more digits. Note that a decimal part alone or a number without digits after the decimal point are not valid, as some might confuse them with valid identifiers or a function with an argument.

These are valid number literals:

  • 009
  • 0.09

These are not:

  • 9. which is a valid identifier
  • 900. which is interpreted as the number 900 followed by the identifier .
  • .9 which is interpreted as the identifier . followed by the number 9

Consider this example where it would be problematic to accept `.9` notation:

function . takes ' does
  print '
  return '
end

var 9. assign .9

The previous code creates a function named `.` which is just a wrapper around the print keyword. The function is then called with 9 as its argument, and the returned value is stored in the 9. variable.

String literal

String literals begin with the keyword string followed by a space. The string may then contain any characters, and ends with a space followed by the keyword end. To write the word end in a string, one must first escape it by typing escape end. Therefore, the following strings:

string Hello, world! end
string   end
string escape end end
string escape escape end

would be equivalent to the following Python strings:

'Hello, world!'
' '
'end'
'escape'

Note that an empty string can be represented with either one or two spaces between the keywords.

Examples

Hello, world!

print string Hello, world! end

which is equivalent to Python 3:

print('Hello, world!')

and produces output:

Hello, world!

Sum of two inputs

var 1# assign prompt string First number:  end
var 2# assign prompt string Second number:  end
var + assign 1# plus 2#
print 1# concat string  +  end concat 2# concat string  =  end concat +

which is equivalent to Python 3:

first_number = input('First number: ')
second_number = input('Second number: ')
sum = int(first_number) + int(second_number)
print(first_number + ' + ' + second_number + ' = ' + str(sum))

and would produce this output if the user entered 10 and 25:

First number: 10
Second number: 25
10 + 25 = 35

Quicksort

function 💨📈 takes § does
  if len § lt 2 then
    return §
  end

  var ¶ assign open
    § at open
      len § idiv 2
    close
  close

  var < assign open
    § method : open
      ' lambda ' lt ¶ end
    close
  close

  var = assign open
    § method : open
      ' lambda ' eq ¶ end
    close
  close

  var > assign open
    § method : open
      ' lambda ' gt ¶ end
    close
  close

  return 💨📈 < plus = plus 💨📈 >
end

which is equivalent to Python 3

def quicksort(lst):
    if len(lst) < 2:
        return lst
    
    p = lst[len(lst) // 2]
    
    less = [x for x in lst if x < p]
    eq = [x for x in lst if x == p]
    more = [x for x in lst if x > p]
    
    return quicksort(less) + eq + quicksort(more)

External links

Tweet which lead to the invention of this language.