Talk:///

From Esolang
Jump to navigation Jump to search

I removed a /// from the bottles of beer program because in my intuition (and in my implementation, although it is simple to adopt that by testing for $s empty) it causes an infinite loop, because every program contains the empty string. Also I disagree that /bar/foobar/bar should print anything, since as I understand the specification, the replacement must be fully completed before a new command can be performed.

Another thing I wondered is whether ][ can be escaped by \ during the initial program transformation. I assumed not in the Perl program. --Ørjan 22:42, 26 May 2006 (UTC)

In my (unpublished) implementation, /bar/foobar/bar is also a nonprinting infinite loop, as is anything else with a self-replacement. It seems that trying to get a useful loop is like trying to program in Muriel; the problem is there is no quotify operation, so one has to be written.
The implementation and program correction is incorrect; there is no ]\n[ construct in the language. The very first replacement is actually /]\n[//, which removes all instances of ]\n[ in the rest of the program; it is the program itself that asks for ]\n[ removal. (There is nothing special about the ]\n[ sequence; if the program started /)\n(//, then )\n( could be used to remove newlines). I'm reverting that change accordingly. --ais523 10:50, 28 May 2006 (UTC)
(Sound of beating head) Doh! On the /bar/foobar/bar point, it should be possible to allow it to print by doing replacement lazily, which could easily be done in a Haskell implementation. This would also allow creating at least one loop in the program. --Ørjan 12:59, 28 May 2006 (UTC)

An ambiguity in the spec

The spec (assuming the article is the spec) does not state what should happen if the program begins with // followed at some point by another / - that is, the "source" is empty. The reference implementation is no help, because an empty pattern in perl evaluates to the last successfully matched pattern (last successful pattern in the perl source, that is) - which probably isn't what the spec author intended. I propose that the most reasonable behavior is for an empty source to match nothing. Here is a modified interpreter:

#!/usr/bin/perl -w

my $debug =
    ($#ARGV >= 0 and $ARGV[0] =~ m/^-d([1-2]?)$/ and shift and ($1 || 1));
$| = 1;

$_ = join '', <>;
while (1) {
        print "\n[", $_, "]" if $debug == 1;
        if (s!^([^/\\]+)!! or s!^\\(.)!!s) {
                print($1);
                print "\n[", $_, "]" if $debug == 2;
        }
        elsif (s!^/((?:[^/\\]|\\.)*)/((?:[^/\\]|\\.)*)/!!s) {
                my ($s,$d) = ($1,$2);
                next if $s eq ""; ###### add this line ######
                $s =~ s/\\(.)/$1/gs;
                $d =~ s/\\(.)/$1/gs;
                while (s/\Q$s\E/$d/) { }
        }
        else { last; }
}

The spec also does not state what happens if the program begins with a /, but does not contain at least two subsequent (un-backslashed) /'s. Here the reference implementation does implement a reasonable behavior ... it terminates without printing anything. I suggest that this behavior also be stated explicitly in the spec.

--Nthern 19:01, 19 August 2010 (UTC)

Whoops - forget that last part; behavior is stated explicitly: "The program ends when there is no longer enough of it to execute" --Nthern 03:20, 20 August 2010 (UTC)
Hm, I've been assuming an empty initial pattern matches every boundary, and so is an immediate infinite loop - that's the mathematically obvious interpretation. However I never tested it (it's useless after all), and I didn't recall it was a special case in perl. --Ørjan 03:31, 20 August 2010 (UTC)
That works too (and may be more mathematically correct). Either way, the reference implementation should be fixed. To implement a deliberate infinite loop, one could change the added line to
while ($s eq "") { };
--Nthern 14:25, 20 August 2010 (UTC)

Clarifying the specs

Cons about precise specs is they are sometimes difficult to read. Especially the "...and the process repeats" at the end. I took the liberty to cut the specs in 3 phases: Source identification, Replacement identification and the Subtitution itself, to make it clear that the substition was restarting from the begining of the string after each substitution. ...That is, if my understanding is correct. --(this comment by AlainD at 10:29, 4 July 2012‎ UTC; please sign your comments with ~~~~)

It is unclear from the specification whether backslashes are considered during the replacement phase. The reference interpreter does not consider backslashes during replacement. For example, the program '/f\oo/bar/foo' prints bar, while '/f\oo/bar/f\oo' prints foo (the pattern does not match f\oo). One could make a case for '/f\oo/bar/f\oo' printing bar as well. 24.16.138.191 16:55, 1 November 2015 (UTC)

In the program '/f\oo/bar/f\oo', the pattern string is "foo", while the remainder of the program is "f\oo"; since "f\oo" does not contain "foo", no replacement is performed. The pattern string is not "f\oo", and the string "f\oo" in the remainder of the program does not "represent" the string "foo" in any way, until it is actually executed. —Tanner Swett (talk) 17:24, 1 November 2015 (UTC)

Links to article

Apparently linking directly to /// has stopped working again. This applies to the mention in the main page and several others. --Ørjan (talk) 22:42, 8 September 2012 (UTC)

This never happened and you are imagining things. ehird (talk) 19:00, 11 December 2012 (UTC)
OKAY! --Ørjan (talk) 10:16, 12 December 2012 (UTC)

Even Faster Counter

I've made a program which should function as a counter, and for numbers 1-3 it seems faster than Ørjan's. However, for some reason it's really slow for anything beyond that. I waited at least an hour with the perl implementation, but it never printed 4.

*
**
***
///

I wonder what's going on :P --Challenger5 (talk) 01:49, 26 February 2017 (UTC)

*bonks Challenger5 on the head* --Ørjan (talk) 02:09, 26 February 2017 (UTC)

Yeah that wouldn't work mate hey, Thats a good meme! (talk) 18:51, 10 January 2020 (UTC)

About the Perl interpreter

I'm quite inexperienced in this wiki, so perhaps this is an out of place proposal, but I would like to propose to remove all "debugging" functionality from the Perl interpreter shown at the end of the page.

Even though we all want to use some kind of "debug mode" when working with an esolang I think that including this functionality in the example implementations shown here may confuse the readers who know the implementation language (in this case: Perl) and want to use these toy implementations to understand the implemented language (in this case: ///).

Note that this will not suppose a huge problem for an user that wants to run some code with all the debug features turned on since a fully featured Perl implementation is linked below.

CarlosLuna (talk) 20:49, 3 January 2020 (UTC)

Sums and substractions

why does this adder not work?

/
//

/+//
/9/8*/
/8/7*/
/7/6*/
/6/5*/
/5/4*/
/4/3*/
/3/2*/
/2/1*/
/1/0*/
/*0/9*/
/0//

5+2

hey, Thats a good meme! (talk) 17:05, 9 January 2020 (UTC)

You are doing the addition before the decimal-to-unary conversion, so, bassically you get 52 asterisk rather than 7. Try this:
   /
   //
   
   /9/8*/
   /8/7*/
   /7/6*/
   /6/5*/
   /5/4*/
   /4/3*/
   /3/2*/
   /2/1*/
   /1/0*/
   /*0/9*/
   /0//
   
   /+//
   
   5+2
CarlosLuna (talk) 09:12, 27 January 2020 (UTC)

i made a subtracter with ///. the input is x £'s-y $'s. This is 3 - 2

/
//

/£-$/-/
/-//
/£/*/

/*/>01//1>/1//10/01//01111111111/1\0//0111111111/_9//011111111/_8//01111111/_7//0111111/_6//011111/_5//01111/_4//0111/_3//011/_2//01/_1//_///>0/>//>//

£££-$$
This program does not handle negative numbers correctly, "£££-$$$$" returns "$" rather than "-*" as I would expect.
I'm currently working in an adder/substractor with arbitrary number of operations and binary input & output (you can take a look at the current version in my user-page). The trickiest part is how to provide binary input AND output ("binary-input & unary-output" or "unary-input & binary-output" are quite easy and "unary-input & unary-output" is trivial). Using binary (rather than decimal) for both, input and output, is quite reasonable with my current approac but I'm thinking in a new approach that will be able to handle decimal too.
CarlosLuna (talk)

Programming quirk?

So here is my /// code:

/\//slash /
/\\/backslash /
//\/\\

And here's what it outputted:

slash \slash backslash slash slash slash slash \

Anyone care to enlighten me and figure out how this happened? - BrightBlackHole (talk) 20:15, 12 November 2020 (UTC)

By the way, the link is here so you can check it out for yourself:

click on this link please thank you
also "added to the pattern and removed". what's that all about?