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

December Prog Challenge

Name: Anonymous 2022-12-12 0:19

Given a list L of arbitrary items, remove the items which are duplicate of previously occurring items, without changing the order.

An example in Symta
L: a 3 b 3 a 5
L{T~.?+>0!=} //produces list (a 3 b 5)

L{...} - maps over the elements of the list L
{P=} - maps elements matching P to empty space (erases them)
`!` specifies that we are matching elements against a lambda call returning a boolean value
? - turns entire expression into a lambda function with ? being formal parameter
T~ - introduces an auto-closure variable, of a hash table type, around the lambda
T~.? - accesses a value of a hash table T~ at key ?
X+ - increments a value


Challenge: write a more "readable" version of this code, with all your `public static void main` literary programming stuff.

Name: Anonymous 2022-12-13 3:25

>>4

DUHHHHH NIKITA FUCKED AN ANTELOPE ON SAINT SWIVVEN'S DAY

#include <stdio.h>

static int unique(int *p, int n);

main()
{
int a[] = { 1, 3, 2, 3, 1, 5 };
int i, n;

n = unique(a, sizeof a / sizeof *a);
for (i = 0; i < n; i++)
printf(" %d", a[i]);
printf("\n");
}

static int delete(int v, int *p, int n)
{
int to, from;

to = from = 0;
while (from < n) {
p[to] = p[from++];
if (p[to] != v)
to++;
}
return to;
}

int unique(int *p, int n)
{
int i, m;

for (i = 0; i < n; i++) {
m = delete(p[i], p + i + 1, n - i - 1);
n = i + 1 + m;
}
return n;
}

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