Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

ed reimplementation contest

Name: Anonymous 2009-09-07 11:18

Let's reimplement ed with modern languages!

10 INPUT
20 PRINT "?"
30 GOTO 10

Name: Anonymous 2009-09-07 11:20

inb4 Enterprise Ed in C#

Name: Anonymous 2009-09-07 11:38

Something about Haskell's [coe]interact[/code].

Name: Anonymous 2009-09-07 12:01

#include <stdio.h>

int main(void)
{
  while (getchar() != EOF) {
    printf("?\n");
  }

  return 0;
}

Name: Anonymous 2009-09-07 12:02

>>1
Nice try Cudder

Name: Anonymous 2009-09-07 12:11

import Control.Monad
main = do getLine >>= (\p -> when (p `compare` "q" /= EQ) $ putStrLn "?" >> main)

Name: Anonymous 2009-09-07 12:13

>>6
Ooops, you can drop the first do. I'm new to HASKAL, forgive me. :(

Name: Anonymous 2009-09-07 12:20

>>7
NO EXCEPTIONS

ed  R *a  W "?",!  G ed

Name: Anonymous 2009-09-08 11:08

Where's the ENTERPRISE C# or Java version?

Name: Anonymous 2009-09-08 12:05

[span]how?[/span]

Name: Anonymous 2009-09-08 12:24

>>5
/* Anonix ed - public domain */

#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void int_handler(int);
void hup_handler(int);

char *prompt = "";

int main(int argc, char **argv){
  char line[LINE_MAX];
  int c;
  while((c = getopt(argc, argv, "p:s")) != -1)
    switch(c){
      case 'p':
        prompt = optarg;
        break;
      case 's':
        break;
      case '?':
        printf("Usage: %s [-p string] [-s] [file]\n", argv[0]);
        return EXIT_FAILURE;
      default:
        abort();
    }
  signal(SIGINT, &int_handler);
  signal(SIGHUP, &hup_handler);
  signal(SIGQUIT, SIG_IGN);
  for(
    fputs(prompt, stdout) && fflush(stdout);
    fgets(line, LINE_MAX, stdin) && strcasecmp(line, "q\n");
    printf("?\n%s", prompt) && fflush(stdout));
  return 0;
}

void int_handler(int n){
  fpurge(stdin);
  printf("\n?\n%s", prompt);
  fflush(stdout);
}

void hup_handler(int n){
  _Exit(0);
}

Name: Anonymous 2009-10-30 8:26

[code]public class Ed {
  public static void main(String[] args) {
    while (true) {
      System.in.read();
      System.out.println("\n?");
    }
  }
}

Name: Anonymous 2009-10-30 9:52

(define (ed) ((read)
              (display '?) (newline)
              (ed)))

Name: Anonymous 2009-10-30 10:35

>>11
using strcasecmp

Name: Anonymous 2009-10-30 10:56

(loop (read-line) (princ "?"))

Name: Anonymous 2009-10-30 15:07

Yeah, I thought about doing that once.

(defpackage #:led
  (:use common-lisp)
  (:export start))

(in-package #:led)

(defvar *edit-functions*)
(defvar *buffer*)
(defvar *dot-l* 0)
(defvar *dot-r* 0)

(defun start (&optional (init-dot '(0 . 0)))
  (setf *edit-functions*
    (list (cons "o" #'open-phrase)
          (cons "!" #'(lambda ()
                (eval (read))
                (wait-for-input)))
          (cons "q" #'quit-editor)))
  (setf *dot-l* (car init-dot)
        *dot-r* (cdr init-dot))
  (setf *buffer* "Here is some default text for testing.")
  (wait-for-input))

(defun wait-for-input ()
  (let ((called-function (assoc (read-line
                 *edit-functions*
                 :test #'string=)))
    (if called-function (funcall (cdr called-function))
        (progn (format t "? ")
           (finish-output)
           (wait-for-input)))))

  (defun open-phrase ()
    (let ((phrase (read-line)))
      (setf *buffer* (replace-dot phrase *buffer* *dot-l* *dot-r*)))
    (wait-for-input))
   
  (defun replace-dot (phrase string dot-l dot-r)
    (concatenate 'string (subseq string 0 (+ dot-l))
         phrase
         (subseq string (+ dot-r) (length string))))

  (defun quit-editor ()
    ; Does nothing yet; will check for changes in the future.
    )

Name: Anonymous 2009-10-30 15:08

Make that,
(loop (read-line) (format t "?~&"))

Name: Anonymous 2009-10-30 15:17

>>16
You're missing a paren after:
  (let ((called-function (assoc (read-line

Name: Anonymous 2009-10-30 15:20

whats an ED program

Name: Anonymous 2009-10-30 15:28

>>19
it's like unix 'yes', except it outputs '?' instead of 'y' and it does it when it reads '\n' on stdin

Name: Anonymous 2009-10-30 16:01

>>18
Weird. Must have been bit rot.

Name: Anonymous 2009-10-30 16:14

>>20
yes | rm *.*

Name: Anonymous 2009-10-30 16:17

>>21
bit rot

Name: Anonymous 2009-10-30 17:48

>>22
rm *.* ? why the fuck not just rm * ?

Name: Anonymous 2009-10-30 17:56

Guess what would be cool. A thread about actual, fully functional ed reimplementations in readers' languages of choice, not reimplementations of the most tired joke in the history of programming. This is about as entertaining or useful as learning that the `hello world' program in a language I've never heard about is approximately ``print "hello world"'' (Thanks, Wikipedia. I really appreciate you).

Name: Anonymous 2009-10-30 18:02

only deletes files with an extension
i.e. README.txt but not README

Name: Anonymous 2009-10-30 18:29

>>25
Hello world is a good example because it usually is able to represent a majority of how the language works.

Name: Anonymous 2009-10-30 19:14

>>27
-module(example).
-export([main/0]).

main() ->
    io:format("Hello world!~n").

Now, how much of the language do you think I have shown?

Unless you write a "hello world" program like
-module(hello).
-export([main/0, printer/1, worker/1]).
-define(NWORKERS, 8).

main() ->
    PID = spawn(?MODULE, printer, ["hello world" ++ [10]]),
    % ?MODULE is a macro which expands to the name of the current module
    lists:foreach(fun(_) -> spawn(?MODULE, worker, [PID]) end, lists:seq(1, ?NWORKERS)),
    ok.

printer([]) -> ok;
printer([C | String]) ->
    receive
        {give_me_a_char, PID} ->
            PID ! {'here you go', C},
            receive {thanks, PID} -> ok end
    end,
    printer(String).

worker(PID) ->
    PID ! {'give_me_a_char', self()},
    receive
        {'here you go', C} ->
            io:format("~c", [C]),
            PID ! {'thanks', self()},
            worker(PID)
    after
        1000 -> timeout
    end.

you aren't going to show even the basics of what makes a language special.

Name: Anonymous 2009-10-30 19:29

>>25
Forgot your sage

Name: Anonymous 2009-10-30 20:28

>>29
Remembered your sage

Name: Anonymous 2009-10-31 14:16

>>30
Haxed your anus

Name: Anonymous 2009-10-31 18:34

Please refrain from posting non-programming related material.

Thank you.

Name: Anonymous 2009-11-02 16:44

>>32

Please refrain from posting "Please refrain from posting non-programming related material.".

Thank you.

Name: Anonymous 2009-11-25 8:03

REFRAIN MY ANUS

Name: Anonymous 2009-11-25 8:30

lets reimplement emacs with modern languages and get rid of that SCHEME shit

Name: Anonymous 2009-11-25 8:37

>>31
I can't even read thatfucking line, i don't give a shti what your views are, get the hell off and drink paint thinner.

Name: Anonymous 2009-11-25 11:40

drink paint thinner
My hobby!

Name: Anonymous 2009-11-25 13:22

>>33
Please refrain from redundant punctuation. Thank you.

Name: Anonymous 2009-11-25 14:01

>>38
plz rfrn frm excss lttrs

Name: Anonymous 2009-11-25 17:04

>>39
>>38
Please refrain from ``Please refrain from''.

Name: Anonymous 2009-11-25 17:36

>>40
Please refrain from using 66faggot quotes99.

Name: Anonymous 2009-11-25 21:34

>>41

Please refrain

Name: Anonymous 2009-11-25 21:34

>>42

Please

Name: Anonymous 2009-11-25 22:46

Name: Anonymous 2009-11-25 22:56

Name: ­ 2009-11-26 6:45

Name: Anonymous 2009-11-26 10:56

Back to the topic!

print "?\n" while(<>)

Of course, VALID PERL CODE

Name: Anonymous 2009-11-26 11:04

[code]
#!/usr/bin/perl
#
#       interjection.pl
#
#   Run in a loop, automating the following sequence of actions:
#
#   1.  Scan front page of selected boards, collect list of threads.
#   2.  Scan thread for erroneous usage of "Linux", in the context of
#       describing a complete operating system.
#   3.  Interject with random Stallman picture and apt pasta, then sleep.
#   4.  At the end of each sweep, sleep for a few minutes before repeating
#       again, ad nauseam.

use warnings;
use strict;

use LWP::UserAgent;
use HTML::Form;
use Data::Dumper;
use DateTime;


my @threads;

my $iteration = 0;
my %boards = ( g => 'zip' );                        # Hash containing boards to sweep.
my $log_file = "$ENV{HOME}/log_interjection";       # Log file location
my @ns_headers = (
    'User-Agent' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.9) Gecko/2009050519 Iceweasel/3.0.9 (Debian-3.0.9-1)',
    'Accept-Charset' => 'iso-8859-1,*,utf-8',
    'Accept-Language' => 'en-US',
);

our $logging_enabled = 1;
our $pic_path = "/mu-nfs/pic/stallman/";            # Directory holding delicious Stallman pictures
our $scan_interval = 240;                           # Interval between each sweep of all boards
our $min_post_interval = 30;                        # Minimum delay after each individual interjection
our $post_interval_variation = 15;                  # Upper threshold of random additional delay after interjecting

our $total_posts = 0;
our @handsome_rms_pics = <$pic_path*>;
our @interjected;                                   # Track posts already responded to.
our $browser = LWP::UserAgent->new;
our $rms_pasta =<<FIN;

open LOGGING, ">", $log_file or die $!;  
print LOGGING "...logging to $log_file\n";



&log_msg("### ------------ interjection.pl ------------ ###");
&log_msg("###");
&log_msg("### \$pic_path:\t\t\t$pic_path");
&log_msg("### \$scan_interval:\t\t$scan_interval");
&log_msg("### \$min_post_interval:\t\t$min_post_interval");
&log_msg("### \$post_interval_variation:\t$post_interval_variation");
&log_msg("###");
&log_msg("### ----------------------------------------- ###");
&log_msg("Entering main loop...");

while (1) {
    &log_msg("Iteration $iteration");
    for (sort keys %boards) {
        # Aggregate listing of threads on front page of board,
        # pass each thread to &scan_posts to read.

        my ($srvr, $board) = ($boards{$_}, $_);
        my $board_url = "http://$boards{$board}.4chan.org/$board/imgboard.html";
        my $page = ($browser->get($board_url, @ns_headers))->content;
        $@ and print STDERR "$!\n";
        push @threads, $page =~ /<span id="nothread(\d+)">/g;

        &scan_posts("http://$srvr.4chan.org/$board/res/$_.html") for @threads;
    }

    &log_msg("Ending iteration $iteration. Will resume in $scan_interval seconds.\n");
    sleep($scan_interval);  # long pause between sweeps.
    $iteration++;
}

sub scan_posts {
    my $thread_url = shift;
    my %posts;
    my $page = ($browser->get($thread_url, @ns_headers))->content;


    # 'name' attribute holds post number, post body is inside blockquote tags.
    %posts = $page =~
        /<a name="(\d+)"><\/a>.*?<blockquote>(.*?)<\/blockquote>/gs;


    for my $no (sort keys %posts) {
        $_ = $posts{$no};
              
        # Strip any remaining tags in post body.
        s/<.*?>.*?<\/.*?>//g;
        s/<.*?>//g;


        # If post contains 'Linux' or some obvious variant, not followed
        # by 'kernel' **AND** no mention of GNU/Linux or GNU plus Linux,
        # then respond.

        if (/L\s*                                   # (L)inux
                (
                    [1i]\W*n\W*u\W*             |   # L(inu)x
                    u\W*n\W*[1i]\W*             |   # L(uni)x
                    [0o]\W*[0o]\W*n\W*[1i]\W*       # L(ooni)x
                )
            x                                       # Linu(x)
            (?!\s+kernel)/ix
                && ! /GNU\s*(\/|plus|with|and|\+)\s*(Linux|Lunix)/i) {

            my $transpose = $1 =~ /u\s*n\s*i\s*/i;
            next if grep {$_ == $no} @interjected;

            &log_msg("URL: $thread_url post: $no");
            &log_msg("POST: $_");
            &log_msg("* Transposed! *") if $transpose;

            &interject($thread_url, $no, $page, $transpose);
            push @interjected, $no;
            $total_posts++;
            &log_msg("Interjection to post $no successful. Freedom delivered! Total posts: $total_posts");
        }
    }
}

sub interject {
    # Prepare pasta, fill form fields, find submit
    # button and click it, then sleep for a semi-
    # random amount of time.

    my ($url, $post_no, $page, $transpose) = @_;
    my ($form, $interjection, $submit_button, $pic);

    $interjection = ">>$post_no\n\n" . $rms_pasta;
    $interjection =~ s/Linux/Lunix/g if $transpose;
    $pic = &select_pic;
    &log_msg("attached pic: $pic"); 

    $form = HTML::Form->parse($page, $url);
    $form->value('com', $interjection);
    $form->value('upfile', $pic);
    $submit_button = (grep {$_->type eq 'submit'} $form->inputs)[0];
    $browser->request($submit_button->click($form));

    sleep($min_post_interval + rand($post_interval_variation));
}

sub log_msg {
    my $msg = shift;
    exit if ! $logging_enabled;
    my $now = DateTime->now;
    syswrite LOGGING, $now->ymd . " " . $now->hms . ": $msg\n" or die $!;
}

sub select_pic {
    # Select a file from the array and remove its entry.

    &log_msg("No more sexy RMS pictures left... ;_;\n") && exit if ! @handsome_rms_pics;
    return splice @handsome_rms_pics, int(rand(@handsome_rms_pics)), 1;
}
[code]

Name: Anonymous 2009-11-26 11:33

>>48
Great spambot bro. Its feels like /g/ has 50% more neckbeard.

Name: Anonymous 2009-11-26 12:03

>>48
#/usr/bin/perl

use strict;
use utf8;

use Board::Request;
use Board::Errors;

# exports $board object, consumes some parts of @ARGV
use Board::Utilities;

$USAGE_ARGS        = "BOARD [OPTIONS]";
$USAGE_TEXT        = <<HERE;
Scans board for replies cintaining "GNU/Linux*" and replies "linux" to them.
HERE

while(1){
    my @threads=@{ ($board->content(PAGE 0) or {})->{threads} or [] };

    for my $thread(@threads){
        my @posts=@{ $thread->{posts} };
       
        my %replied;
       
        for(reverse @posts){
            my $num=$_->{num};
           
            if($_->{comment}=~/^>>(\d+)\s*linux$/s){
                $replied{$1}=1;
                next;
            }
           
            next unless $_->{comment}=~m!GNU/Linux\*!;
            next if $replied{$num};
           
            $board->post(
                parent        => $_->{parent},
                password    => 'qwerty',
                comment        => ">>$num\nlinux",
            );
           
            print ucfirst $board->errstr,"\n" and next if $board->error;
           
            print "[$_->{num}]\n";
        }
    }
   
    sleep 10;
}

Name: Anonymous 2009-11-26 13:56

>>50
EXPERT PERL PROGRAMMER

Still no ed

Name: Anonymous 2010-12-17 1:27

Xarn is a bad boyfriend

Name: Anonymous 2011-02-02 22:53

Name: Anonymous 2011-04-01 15:10

?

Name: Anonymous 2011-04-01 15:26

>>35
Know your trolling but new Zile is in lua.

Name: Anonymous 2011-04-01 21:01

/prog/ is dead

Name: Anonymous 2011-04-01 21:03

/prog/ is dead

Name: Anonymous 2011-04-01 21:05

/prog/ is dead

Name: Anonymous 2011-04-01 21:06

Long live /prog/!

Name: Anonymous 2011-04-01 21:08

Long live /prog/!

Name: Anonymous 2011-04-01 21:09

Long live /prog/!

Name: Anonymous 2011-04-01 21:11

/prog/ is dead

Name: Anonymous 2011-04-01 21:12

/prog/ is dead

Name: Anonymous 2011-04-01 21:14

/prog/ is dead

Name: Anonymous 2011-04-01 21:16

/prog/ is dead

Name: Anonymous 2011-04-01 21:17

/prog/ is dead

Name: Anonymous 2011-04-01 21:19

/prog/ is dead

Name: Anonymous 2011-04-01 21:20

/prog/ is dead

Name: Anonymous 2011-04-01 21:22

Long live /prog/!

Name: Anonymous 2011-04-01 21:24

/prog/ is dead

Name: Anonymous 2011-04-01 21:25

/prog/ is dead

Name: Anonymous 2011-04-01 21:27

Long live /prog/!

Name: Anonymous 2011-04-01 21:28

Long live /prog/!

Name: Anonymous 2011-04-01 21:30

Long live /prog/!

Name: Anonymous 2011-04-01 21:32

/prog/ is dead

Name: Anonymous 2011-04-01 21:33

/prog/ is dead

Name: Anonymous 2011-04-01 21:35

/prog/ is dead

Name: Anonymous 2011-04-01 21:36

/prog/ is dead

Name: Anonymous 2011-04-01 21:38

Long live /prog/!

Name: Anonymous 2011-04-01 21:40

Long live /prog/!

Name: Anonymous 2011-04-01 21:41

Long live /prog/!

Name: Anonymous 2011-04-01 21:43

/prog/ is dead

Name: Anonymous 2011-04-02 2:42

bf
++++++++[>++++++++<-]>-<+[,>.<]

Name: Anonymous 2011-08-13 11:30

PLEASE REIMPLEMENT MY ANUS

Name: Anonymous 2011-08-13 11:36

This thread is a good reminder of how quickly /prog/ turned to shit.

Name: Anonymous 2011-08-13 13:26

>>85
screw you gramps, /prob/ is the future

Name: Anonymous 2011-08-13 14:10

(loop (print (eval (read))))

Name: Anonymous 2011-08-13 16:34

>>40

please refrain from NIG­GERS

Name: Anonymous 2011-08-13 16:35

NIG­GERS NIGGERS NIGGERS NIGGERS JEWS

Name: Anonymous 2011-08-13 18:50

HERE, HAVE SOME POLECAT KEBABS ON ME

Name: Anonymous 2011-08-13 20:52

>>90
Fuck off, ``faggot''.

Name: Anonymous 2011-08-13 21:38

>>91
Polecat Kebabs are delicious. Don't be such a negative Nancy.

Name: Anonymous 2011-08-13 22:56

>>88-89
* African American

Name: Anonymous 2011-08-13 23:22

>>93
nigstorm faggot

Name: Anonymous 2011-08-13 23:30

>>94
* Tempest of African Americans' Homosexual

Name: Anonymous 2012-04-02 5:07

>>95
* Strong rainy and windy weather of individuals coming from the continent found south of the Mediterranean Sea having sexual preferences unapproved by the Catholic Church

Name: Anonymous 2012-04-02 5:57

puts ?? while gets

Name: ? 2012-07-27 10:46

?

Name: Anonymous 2012-07-27 10:54

checkem

Name: Anonymous 2012-07-27 10:57

>>99 fuck you, your doubles and mine's

Name: Anonymous 2012-07-27 11:06

>>96
Any news on when the "Homosexuals Try Making Love" 5 standard will be ratified by the X3C?

Name: Anonymous 2012-07-27 11:21


#!/bin/sh
ed

Name: Anonymous 2012-07-27 12:12

>>101
Homosexuals Try Making Love
i lol'd

>>102
that's not even a reimplementation, it's just an indirect way to calling original ed unless this script itself is called ed and put into $PATH so it's called recursively, in which case                                                         IHBT

Name: Anonymous 2012-07-27 12:38

while true;do read;echo ?;done

Name: Anonymous 2012-07-27 12:43

>>25
the most tired joke in the history of programming.
And who crowned you the king of humour?

Name: Anonymous 2012-07-27 20:36

sed -e "/q/{s///;q};s/.*/?/"

Name: Anonymous 2012-07-27 22:16

>>105
VIPPER did

Name: Anonymous 2012-07-28 0:40

Shiki Yami Barai

Name: Anonymous 2012-07-29 4:55

>>106
Excellent.

>>107
Fuck you, dipshit.

Name: Anonymous 2012-07-29 5:03

jack be nimble
jack be quick
jack sucked on my fuckin' dick

Name: Anonymous 2012-07-29 7:10

Jack be trebs

Name: Anonymous 2012-11-30 11:20

Jack be Pròxima estació: Sabadell Rambla. Aquest tren finalitza el seu recorregut en aquesta estació

Name: Anonymous 2012-11-30 11:59

% yes \?

Name: Anonymous 2012-11-30 12:22


echo off
:l
set /p a="?"
echo ?
goto l

Name: Anonymous 2013-09-01 14:46



It’s from the Germanic root gel which has produced both English yellow and German gelb (OED).

Don't change these.
Name: Email:
Entire Thread Thread List