last day (15 days later) » 

22:18
-9
Q: Number and decimal to array without strings

guest271314Write a function that takes input as an integer, or decimal number and outputs an array containing the integer or if a decimal number includes the last integer and decimal separator portion of input set as a single element with remaining integer and decimal portions of input set as adjacent eleme...

The second test case does not appear to be consistent with the result. Also, I don't understand the last two outputs - why are they invalid? What does the part before them mean?
@JoKing "How do we take an irrational number?" Not sure what you mean? You write the code.
I find the spec unintelligible and have to reverse engineer it from the test cases, but the tests don't cover all of the corner cases I can think of. What about doubles which are so large that they format to e.g. 1e+45? What about doubles which are very small, such as -1E-12? Or is I/O all in terms of strings rather than doubles?
@Doorknob What specifically about the second test case does not appear to be consistent to you? The last two examples are intended to depict a plain or golfing language function or procedure within a function which converts the input or output to a string during the procedure.
@PeterTaylor e used in a language such as JavaScript is an artifact of computer science and the technology of the day and is not the number e. The test cases at the question are exhaustive enough for the present inquiry. If you decide to contribute further defensive code in an answer kindly do so in an answer to the question.
@JoKing Yes, an irrational number infinite, though output can be stopped at the 20th decimal place, or the maximum output of the language used. Have written code in JavaScript which converts a number to an array without using string methods, omitted from the question body; came across this issue when passing irrational numbers or simply 1.5; considered numerous approaches, decided to post the question here to see how the users here would approach the case. Vote to close the question if you do not like the question.
The proper action for an unclear question shouldn't be for users to close the question, but for the poster to clear up the confusion.
22:18
@JoKing What is confusing to you? Should the current JavaScript code which does not return the expected result be included at the question?
@JoKing e, Pi, φ are irrational numbers. As indicated at a previous comment, output can be stopped at the 20th decimal place for input that is an irrational number, which would in any case be the maximum output possible for that language or computer system itself. The output is not expected to be an infinite irrational number being generated to an output array. None of the examples at the question exceed 20 decimal places after the decimal. 0.5 is a decimal number that is not an irrational number which should be output as [0.5].
@JoKing, "unclear" is a top-level close reason for a reason. Ideally OP will fix the question before the 5th vote is cast, but if the question is closed, clarified, and then reopened then the system is working as it should.
How do we distinguish 100.01[1,0,0.0,1] and 10001[1,0,0,0,1] in a language where 0.0 and 0 are the same?
@Adám Do not use that language to answer this question; or, do your best to achieve the requirement given the circumstances and explain the limitations of the language at an answer; or make it so that language does distinguish between the two? Or, avoid the question? Not sure; you decide. The requirement should be achievable though have not yet achieved it here using JavaScript language, yet.
Is it possible to take input and output as a string?
22:18
@user202729 No. The requirement is to specifically not use string as input, output or convert the input or output to a string during any part of the procedure.
@user202729 Not sure what you mean?
Can we write a full program?
@user202729 Yes, as long as no built-in or specialized string conversion or coercion methods are used.
@guest271314 But input, if given from STDIN, is already a string.
@guest271314 So you're ruling out languages that cannot distinguish ints and floats and also languages that cannot have ints and floats in the same array? Certainly, JavaScript is ruled out, as it doesn't have ints at all.
@Adám Then solve the question to the best of your abilities using a language that can achieve requirement. Or, post an answer stating the requirement is not possible. Or, post an answer providing an alternative method of representing a decimal in an array without using any string methods. chat.stackexchange.com/transcript/message/47663516#47663516. Or move on from the question and be done with the inquiry. The question will probably be closed and will find a way to solve problem for self.
22:18
@guest271314 Would [1,0,[0,0],1] be acceptable for 100.01?
Or how about [[1],[0],[0,0],[1]] for 100.01?
@Adám Ideally the array should be flattened with the decimal being apparent in the output array.
@guest271314 Ideally? Either you allow it or not. Please answer for each of those if it is OK or not.
@Adám No, not allowed
@guest271314 What is the correct output for -0.05?
@Adám According to the question it should be [-0.0,5]
22:18
@guest271314 OK, so the problem is also only solvable in languages that distinguish -0.0 and 0.0. You really should include all your language assumptions in your post.
@Adám There are no assumptions. The question is clear. If you intend to find loopholes you will. If you propose an alternative solution which does not involve nested arrays or strings then post that at an answer. Concentrating on zeros and the issues with languages does not resolve the question. If individuals can write languages with a myriad of characters identifiable only by the neophytes of that language to represent procedures, they should be able to write an answer which represents decimals [0.5] or [0.0] which are in use in a wide range of applications throughout this world; or not
1 2 3 4 5 Bingo!
@Adám Not sure what the links are intended to convey besides those users' opinions. Walk through "don't"s to the other side.
@guest271314 They're more like the whole community's opinions...
@JoKing Ok. That is "community's" opinion = opinion. Am not bound by "community's opinions" by any sort or measure. And cannot get into users' minds to formulate a question from within their minds, they way they understand the world. The question is clear. If there are other grounds to close the question, then use those means, or continue in the same fashion as "unclear". Or, suggest an alternative approach which does not use string methods at an actual answer.
22:18
@guest271314 is ["-",0,".",0,5] acceptable for -0.05?
@Adám No. No strings. Though perhaps Symbol or the like in the language used could be employed, and if employed in an answer, then means to parse such a formulation to and from decimal to array must be included at the answer.
@guest271314 You question doesn't say literal strings are prohibited, only that Built-in or implicitly converting string methods must not be used to process input or output.
@Adám Yes, it does. Read it carefully. It is said more than once and at comments. If that is not clear enough for you will state it again, here and now. No strings are allowed within the procedure at all; whether cast, coerced to, literal or otherwise. If that is not possible in any language, that is a viable answer. If you choose not to post that answer, but focus on parsing some loophole in the question, that is your choice.
@guest271314 Can you quote me the exact text in the question? 6
@Adám You quoted the line yourself, at "Rules". You simply have chosen to attempt to invoke some other meaning as legalese than the direct language "Built-in or implicitly converting string methods must not be used to process input or output."
22:18
@guest271314 I understand that you don't want the input to be manipulated as a string, but prohibiting string methods doesn't prohibit using literal strings in code, does it? What if one needs some non-string method with a parameter where the parameter is a string? Is that also disallowed‽
@Adám Yes, it does. No usage of strings, period within the function. That case is absurd. The input and output itself must not be converted to or from strings or added to or subtracted from by any string method. In the same manner that will not permit language legalese to implicitly insert that string literals are omitted from the question requirement. Though for clarity will update the question to state that, directly, again.
@guest271314 Are we allowed to use alternative glyphs for - and .? E.g. [false,0,true,0,5] for -0.05?
@Adám As long as you provide the means to convert what you create back to a number. Though, that too, is deviating from what am trying to achieve; or, demonstrate the lack of this ability in modern languages in spite of the lists and lists or languages which go out of their way to incorporate elaborate glyphs as their primary usage interface in as tiny a symbol as can be devised - though apparently few, if any - can even output [0.0]
Needs more "close" vote!
I find the question mostly understandable (besides the fact that there's no way you can tell whether my answer uses strings because on PPCG we test an answers correctness by the interpreters implementation, not what the answer means; also, is a char[] a string? Is a byte[]? What even is a string?!?), but that doesn't mean the question is good. The "Things to avoid when writing challenges" meta question is both for things to avoid for your question to be easily understandable, and things to avoid for people to like the question, both of which are problems to you.
@guest271314 3 seconds late :-( Would this have been acceptable? To regenerate the number, just replace ⎕SE with - and # with . and then squash it all together. ⎕SE and # are built-in symbols.
22:18
@Adám Interesting. Have no experience using APL. Do you use any strings?
@guest271314 Well, it is never to late to learn it, and it is good fun too. Of course I don't use strings, only arithemetic and structural manipulations. I'll be happy to explain it if you want.
@Adám Consider this answer stackoverflow.com/a/34944050. What am essentially trying to achieve is when a decimal exists to get the fraction part in its own index [123,Math.E,321.7000000001,809.56,1.61803398874989,1.999,100‌​.01,-7,-83.782,12‌​,1.‌​50] -> [[1,2,3], [2, 0.7, ...], [3,2,1,0.7,...], [8,0,9,0.5,5,...],[1,0.6,1,...], [1,0.9,9,9...],[1,0,0,0.01,...], [-7], [-8,-3,-0.7,8,...], [1,2], [1,0.5]] we should be able to count the indexes to determine the decimal place when reconstructing; e.g., -8*10+-3+-0.7. Will update the question
@guest271314 Ah, now it makes much more sense, and will be possible in most normal languages. However, this post has been downvoted to oblivion. I suggest sandboxing a fresh question.
@Adám Am not concerned with "down" votes. Am trying to break down an integer or decimal number into into lowest integral parts, with the fractional part preserved at that place in the output array - without using string methods. If you have further suggestions, kindly post them here and will edit the question.

last day (15 days later) »