Skip to main content
Commonmark migration
Source Link

Haskell, 26 18 bytes

main=print$0 +1-- 

Try it online!

Doubled:

main=print$0 +1--main=print$0 +1-- 

Try it online!

I found this version while answering the tripple version of the challenge.


26 byte version without comment abuse:

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f]Try it online! Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Haskell, 26 18 bytes

main=print$0 +1-- 

Try it online!

Doubled:

main=print$0 +1--main=print$0 +1-- 

Try it online!

I found this version while answering the tripple version of the challenge.


26 byte version without comment abuse:

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Haskell, 26 18 bytes

main=print$0 +1-- 

Try it online!

Doubled:

main=print$0 +1--main=print$0 +1-- 

Try it online!

I found this version while answering the tripple version of the challenge.


26 byte version without comment abuse:

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

Try it online! Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached.

added 612 characters in body
Source Link
Laikoni
  • 26.4k
  • 7
  • 54
  • 116

Haskell, 2626 18 bytes

main=print$0 +1-- 

Try it online!

Doubled:

main=print$0 +1--main=print$0 +1-- 

Try it online!

I found this version while answering the tripple version of the challenge.


26 byte version without comment abuse:

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Haskell, 26 bytes

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Haskell, 26 18 bytes

main=print$0 +1-- 

Try it online!

Doubled:

main=print$0 +1--main=print$0 +1-- 

Try it online!

I found this version while answering the tripple version of the challenge.


26 byte version without comment abuse:

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

added 394 characters in body
Source Link
Laikoni
  • 26.4k
  • 7
  • 54
  • 116

Haskell, 26 bytes

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

Try it online! [Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Haskell, 26 bytes

main|n<-1,nmain<-2=print n 

Try it online!

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

Try it online!

Haskell, 26 bytes

main|n<-1,nmain<-2=print n 

Try it online! Prints 1.

In the pattern guard the identifier n is set to 1 and nmain to 2, then print n prints 1.

###Double program:

main|n<-1,nmain<-2=print nmain|n<-1,nmain<-2=print n 

[Try it online!][TIO-j55yf85f] Prints 2.

In the first pattern guard again n is set to 1 and nmain to 2, however the print statement has become print nmain, so 2 is printed. Because identifier declarations in a pattern guard evaluate to true, the second pattern guard can never be reached. Haskell: https://www.haskell.org/ [TIO-j55yf85f]: https://tio.run/##y0gszk7Nyfn/PzcxM68mz0bXUCcPxLTRNbItKMrMK1HIwy3z/z8A "Haskell – Try It Online"

Source Link
Laikoni
  • 26.4k
  • 7
  • 54
  • 116
Loading