Erlang Radix Syntax, and Lambda as the Ultimate Meaning

Follow Up to “Gotcha with Bitstrings”  

   How to ACTUALLY denote binary numbers in Erlang

After I put the previous post together, I went looking if there was a way for the Erlang lexer to tell if a number is binary, or octal, or hex.  Well it turns out: yes, and it is a beautiful bit of syntax.  
All you do is put the radix (a.k.a. the base) in front of the number and then use the pound-sign ‘#’ to separate them:

As you can see, the literal 2#01000001 is stating:  “use base-2, and treat the numeral after the pound-sign as binary”. The syntax  <<2#01000001>> on line 128 is bitstring syntax and was the subject of the last post. The evaluation of a naked number inside the chevrons shoves that number into a 8-bit least-significant segment which, in this case, does not truncate any bits. The 65 decimal number is interpreted as the literal UTF-8/ASCII value of "A". They are the same.

If we try to use a non-binary glyph/symbol (like a ‘2’) for instance, we will get a problem:
We can do hex too, by using 16 as the radix:

This little bit of syntax is allowed for radices up to 36 (presumably because nobody would agree as to what new glyphs/symbols we should use after we have exhausted the Indian Numerals and the Latin Basic Alphabet).

If we ever do try to adopt extra glyphs for a > base-36 system.  I suggest the one above (hereafter known as the Eklund Encoding), as it makes lambda the answer to life, the universe, and everything.

Although for generating tiny URLs from UUIDs without accidentally offending someone, I suggest the crockford encoding.

23 comments:

  1. Hi, Very nice article. I hope you will publish again such type of post. Thank you!
    Akshi is the largest CNC Roll Turning Lathe Machine Manufacturers, supplier, and exporters in India. We provide a variety of items, minimize workforce, avoid manual mistakes and offer cost-effective solutions.

    ReplyDelete
  2. Find out the most premium health and beauty products in Pakistan at Posch Care that is stocked with a wide variety of skin care items for you.

    ReplyDelete
  3. Lovine is one of the well-known online Cosmetic platforms in Pakistan for Women and Men items.

    ReplyDelete
  4. ในตอนนี้แบรนด์ Clubred666 ได้มีค่าย สล็อตเว็บตรง ทั้งหมดได้นำมาให้ผู้เล่นหรือลูกค้ามือใหม่ได้ร่วมสนุกกับตัวเกมส์แล้ว เพราะทาง Clubred666 อยากให้ลูกค้ามือใหม่และลูกค้าที่เป็นขาเป็นจำได้สนุกกับตัวเกมส์ที่ทางเว็ป PG Slot

    ReplyDelete
  5. Keep on posting articles like these. It is a nice interesting post. Keep it up the good work. Now its time to avail Best Roller Shutter Repair services in London for more information.

    ReplyDelete
  6. pgslot1234 สล็อตออนไลน์ การพนันหรือเกมคาสิโนในต้นแบบออนไลน์นั้นจะต้องบอกเลยว่าหนึ่งในเกมที่มาแรงที่สุดนั้นจำเป็นที่จะต้องชูให้กับเกมตู้ยอดนิยมอย่าง PG สล็อต อย่างแย้งมิได้

    ReplyDelete
  7. slot-web-ตรง สล็อตเว็บตรงคือเว็บไซต์ที่ให้บริการเกมสล็อตออนไลน์โดยตรง ไม่ผ่านเอเย่นต์หรือเว็บไซต์กลุ่มอื่นๆ PG SLOT ซึ่งสล็อตเว็บตรงนั้นจะมีความน่าเชื่อถือและมั่นคงมากกว่า เนื่องจากมีการดูแลและบริการลูกค้า

    ReplyDelete
  8. pg ultrabet88 เล่นง่าย จ่ายจริง เป็นเรื่องง่ายและไม่ซับซ้อนเลยทีเดียว โดยสามารถทำได้โดยติดต่อผ่านทางเว็บไซต์หรือแอปพลิเคชัน pg slot ซึ่งสามารถใช้งานได้ในมือถือ

    ReplyDelete