Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Currently, when a user here gets a 404, they see the following image:
Which represents the text:
# define v putchar
# define print(x) main(){v(4+v(v(52)-4));return 0;}/*
#>+++++++4+[>++++++<-]> ++++.----.++++.*/
print(202*2);exit();
#define/*>.#*/exit()
This looks suspiciously polyglottish. Which languages does this do something interesting in?
Side thought: Is it just me, or did I find a bug in Prettify?
It is C and brainf**k. They both print 404.
Line 4 with the print(202*2) is valid in any number of scripting languages like Perl, Ruby, ECMAScript (provided a suitable implementation of a print function) and probably Python.
Line 2 is there to make line 4 valid in C and Objective-C, maybe also C++ and Objective-C++.
Line 3 contains some Brainfuck, but there seems to be something else there.
I have no idea what line 1 with the v is for. Why not just call putchar directly in line 2? So, I suspect that there's another language that is somehow made valid through this line. (At first I thought about Whitespace, but there's not enough whitespace in there to be a valid Whitespace program.)
And line 5 obviously also contains some code in some highly compressed language. Maybe something in the APL family (J, K, ...) or Golfscript?
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I type this into my texteditor:
boombang xs = [ if x < 10 then ”BOOM!” else ”BANG!”
But when trying to load it, my terminal denies it and and says:
Probably some dumb rookie mistake, but I can't seem to find the solution...:/
There are two problems here.
The first is, you're not using plain ASCII quotation marks (U+0022) ". You're using right quotation marks (U+201D) ”. There's probably a keyboard setting you're using that's causing this, and using certain text editing programs can also prevent this.
Secondly, you seem to be either missing a right bracket. As pointed out, this is probably meant to be part of a list comprehension. You need to write all of the list comprehension for it to work.
The corrected code is:
boombang xs = [if x < 10 then "BOOM!" else "BANG!" | x <- xs]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to know about simple problems that can be naturally solved using stacks with the usual interface (emptyS, isEmptyS, push, pop, top).
The complexity asociated to the context of the problem should be null. I can't touch topics like parsing, compiling or search algorithms at this moment. This discards many classical examples.
The most beautiful example I found so far is checking for balanced parenthesis in strings. In very few lines, without any other background, the exercise shows the utility of the data structure:
Another good example is procesing a string where the asterisk means to pop an item from the stack and a letter means to push it into the stack. The function must return the stack after the operations described in the string are applied to an empty stack.
If you can share some others problems, I will apreciate it very much.
Thank you in advance.
Though this question is too broad, I am going to give some other applications. Some of other common applications are -
Parsing
Recursive Function
Calling Function
Expression Evaluation
Expression Conversion
Infix to Postfix
Infix to Prefix
Postfix to Infix
Prefix to Infix
Towers of Hanoi
Some details can be found here.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
we've been given the task to make a Dictionary, as a List of tuples with (String, String).
The problem here is that I actually have no idea if I can rename String twice at the same time, since I want the tuple to look like this
(German, English)
Is it even possible to just make it look like this?
type German = String
type English = String
type Dictionary = [(German, English)]
Or would there be any conflicts?
It was kinda frustrating not finding a single entry about this, been almost 2 hours and not a single line of code stands right now :|
Yes, you can do that. You can't do the opposite
type German = String
type German = Int -- conflicts here!
Of course you can, if you couldn't, you wouldn't be able to compile type German = String in the first place, as it's already been named ;-)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Quick question, is there any difference between these two following bits of code?
Example 1
print("hello,", end='')
print(" world")
Example 2
print ("hello, world")
I don't see a difference in output, why would I use one over the other?
Thanks in advance for any answers
You would only really use the first one in cases where you may want to keep outputting things onto the same line (think logging something onto one line in a loop for some reason).
Otherwise use the simpler option.
If you use end='' it avoids the newline that python normally inserts in a print statement.
In practice, there's no reason to do it the first way with a short string like that, but if you wanted to put other variables in the output, it could be useful.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
Is there a source where I can get multiple simple programs like addition, factorial, fibonacci and others for the brainfuck programming language?
I know that there has been a question posted before here : https://stackoverflow.com/questions/3554670/tutorials-for-brainfuck
But I would like to have a list of simple programs, short bite-sized programs to get comfortable with the language. Any help is welcome. Thanks.
I believe the Wiki article had some simple examples of BrainFuck code. Brainfuck
As for Fibonacci, here's a page with some code (not mine, mind you) generating the Fibonacci sequence up to one hundred. Brainfuck, Fibonacci sequence
Do note that the classic Brainfuck interpreter uses byte variables to store memory cells. So if you'd like a factorial, it wouldn't get you much further than 5!.
Nonetheless, I've found an example for you. Brainfuck, Factorial
Extra reading: Simple, and not so simple programs in Brainfuck