Talk:Unary

From Esolang

Jump to: navigation, search

Heh, cool. I once made something like this, but quickly scapped it. Now I just have to write an Unary interpreter or something. XD Hmm. Apparently hello world is 0x2924924962924922924924914914000F94A15124925224A14A00924924924928624A36DB71B6DB6E150C 0's.

YET ANOTHER edit here. I just made a brainfuck-to-unary converter in Thue. http://www.filenotfunny.com/bf2un.t Please notify me of any bugs blah blah etc. EDIT: You guessed it, unary-to-brainfuck converter in Thue. http://www.filenotfunny.com/un2bf.t --BodyTag 18:25, 11 Sep 2005 (GMT)

Great, now how to run it without running out of memory :) --Aardwolf 20:46, 11 Sep 2005 (GMT)
Well there's the obvious approach. Make shorter programs. :P --BodyTag 21:01, 11 Sep 2005 (GMT)

Contents

[edit] One character language

Hey, this finally gave me the idea how to create a language that uses only one character! Yihaaaaa! I've been so stupid for not seeing it before.. --User:Keymaker

But this language has two symbols: 0 and EOF. The fact that it uses one character is merely a technical detail. --Graue 21:27, 11 Sep 2005 (GMT)
Oh please.. :) Would it be necessary to count in the EOF for some reason when making one character language? --User:Keymaker
Surely EOF is meta-data, and not part of the program data itself? --Safalra 13:51, 20 Oct 2005 (GMT)
Absolutely not; how else can an implementation make any sense of how to run the program, other than by looking for the EOF symbol? --Graue 14:26, 20 Oct 2005 (GMT)
Yeah, EOF is part of the program data, but this would count not only for Unary but also for all other languages. Then BF has not 8 but 9 symbols, since when the end of BF code is reached, it is interpreted as finish program. This is then also something to be considered in the BF minimization page. --Aardwolf 14:36, 20 Oct 2005 (GMT)
Iota and Unlambda don't require EOF. --Ihope127 15:20, 20 Oct 2005 (GMT)
Use meta-data, as I said. In Javascript, use document.forms.name.field.value.length, in Java use String.length(). EOF is just a way of representing the end of a file as a character, for languages that don't provide any other way of finding the length/end of a file (or don't have an exception system, so want a call to a next() method to always return), or for programmers who know that a while(c>-1) loop runs faster than a while(!eof()) loop. --Safalra 14:56, 20 Oct 2005 (GMT)
OK, then how do you propose storing that metadata with one symbol? --Graue 15:00, 20 Oct 2005 (GMT)
It's meta-data, so it doesn't get stored as part of the program - it's an implementation detail and can be stored in any way. The program code is an abstraction - if I compress a Unary program, the compressed file may use a variety of symbols, but the Unary program it represents still contains just one symbol. Saying that EOF is part of the language is like saying a 2D language needs a end-of-row symbol as well - of course we could instead use an end-of-column symbol, or specify that the program is padded so that it's width and height are prime numbers, with its width being greater than its height. The point I'm making is that these implementation details are all meta-data, and not part of the program. --Safalra 16:38, 20 Oct 2005 (GMT)
Definitely agree with that. --User:Keymaker
EOF isn't a printable symbol in this programming language, yet in some way it seems to be semantically significant, therefore it must exist in some form. If a Unary program were to be printed on paper, the EOF would be the end of the paper, or the space where the next 0 would be, if there was a next 0 in the first place. Therefore IMO, Unary has 2 symbols. Many of you don't want to thus change the definition of Brainfuck as being a language consisting of 9 symbols, but this is probably just humans being resistant to change. We've defined it as 8 symbols for so long, why change it now..? :) Also, I just wondered.. we could construct a language implementing the same semantics, but with an infinite amount of symbols. Just let the Unary program be represented instead by a positive integer whose value is the number of zeroes. --Anonymous

[edit] Joke Language

Should Unary be considered a joke language, since in a way it's unique. --Aardwolf 15:00, 22 Oct 2005 (GMT)

[edit] Attempt at Python converter

I've tried to make a Brainfuck to Unary converter in Python(currently at [1] However, I'm having two problems with it. The first is that I don't know how to convert numbers from binary to unary in Python. The second is that I can't get the programs to show up right in the Unary to Brainfuck converter if I convert the number by hand.

Does anyone have a clue on how to fix this? 83.109.228.9 16:14, 1 April 2008 (UTC)

For binary to unary, start with a number at zero, then repeatedly double it if the first digit of the binary is a 0, and double it and add 1 if the first digit of the binary is a 1, going through all the digits of the binary number in order; that will give you the length of the unary output you need to produce. (You'll need to use an unbounded integer to do this, otherwise the number will overflow.)

[edit] How can a Unary Number System possibly exist?

Read above. Essentially, Unary being base 1 must include all the Whole Numbers up to but not including 1. Thus, we have a range of {0}. Now, using this system, we create an arbitrary number, say 000000 which would be (what we think) the equivalent of 6d or 00000110b. However, if we evaluate our unary number, we come to a problem: 000000 = 0*1^5 + 0*1^4 + 0*1^3 + 0*1^2 + 0*1^1 + 0*1^0 = 0 This is of course a problem, because we cannot use only 0's as we will never have a value other than 0 (being the multiplicative dead) and if we use a 1 then this turns into binary by virtue of the existence of two symbols and the fact that it includes all the whole numbers up to but not including two.

So, from the above, is Unary merely a fancy term for "tally using 0's", otherwise I cannot see a way it can possibly function. -- Hiato 11:24, 4 April 2008 (UTC)

Unary generally refers to a number system where the number of digits represents the size of the number; there is usually only one digit, but that digit is usually 1 (thus an example number would be 111111 = 1*1^5 + 1*1^4 + 1*1^3 + 1*1^2 + 1*1^1 + 1*1^0 = 6). This doesn't exactly follow the pattern used by the other number systems, though. (The base really determines the base of the exponent, rather than the digits used; think about base -2, for instance, which uses 2 digits but has -2 as the base for exponents when calculating digits.) --ais523 09:20, 5 April 2008 (UTC)

In this program we use zeros but they say unary is uaually 1's. One way to do it, is you can use any characters you want in the program, the interpreter will ignore the actual contents of the file and read only the size of the file. This will break if the file has a newline or EOF mark at the end, but the programs that do that can be fixed. In this way, you can also make sparse files in a NTFS file system that are larger than the drive can contain, and it will still work. Of course, even the file size field might not store a large enough number, but the other conversion programs are no better. --Zzo38 14:22, 5 April 2008 (UTC)

Oh, I see - thanks. So essentially Unary is just a fancy tally (as 1^n = 1, n e Q) as opposed to a "true" base n number system. Is this to say that what I put forth would be some kind of Nullary (Base 0 number system?) -- Hiato 20:27, 13 April 2008 (UTC)
Yes, pretty much. I don't blame you for being confused; the standard terminology is inconsistent and confusing. --ais523 20:32, 14 April 2008 (UTC)
Personal tools