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

Pages: 1-

Prog Challenge

Name: Anonymous 2022-10-26 12:36

We all know the classic magic numbers, like 0xcafebabe and 0xdeadba11

But are there more? Write a routine which given an english dictionary finds all words re-presentable in hex that way.

Challenge: make it O(n)

Name: Anonymous 2022-10-26 12:41

1 = 1
5 = S
7 = T

Name: Anonymous 2022-10-27 5:46

let words = [];
foreach(let d : dict) {
if(d.all(l : '157abcdef'.contains(l)))
words.add(d)
}

o(n)

Name: Anonymous 2022-10-27 5:54

aww naww fucken balles they deadass removed my coad tags from the prague forum

Name: Anonymous 2022-10-27 11:28

>>3
this is not O(n)!!

Name: Anonymous 2022-10-27 12:24

>>5
It is o(n) if n is the length of the dictionary.

Name: Anonymous 2022-10-27 22:18

>>3
You forgot to replace the words lst with "157".
So you have failed the junior java retard interview.
Cuz everywhore knows you will push untested code into production.

Name: Anonymous 2022-10-29 14:49

(defun hex-char-p (char)
(member char '(#\a #\b #\c #\d #\e #\f #\l #\t #\s)))

(defun hex-word-p (word)
(if (zerop (count-if-not #'hex-char-p word))
word
nil))

(defun find-all-hex-words (words)
(remove-if #'null (mapcar #'hex-word-p words)))


Sorry, I don't know how to make it efficient without making it ugly.

Name: Anonymous 2022-10-29 16:20

>>8
Sorry, I don't know how to make it efficient without making it ugly.
Try Symta:
Ws.keep ?all^|'157abcdef'.has ?(l=1;s=5;t=7)

Most of it is self explanatory due to the incrediblly readable and intuitive nature of Symta syntax, except ?(l=1;s=5;t=7) which is just a regex-like pattern matcher, which works like that: https://imgur.com/a/v0u89V8

Symta was born out of desire to add Haskell-like syntax to Common Lisp, while keeping macros. In fact, Symta also has lexical macros, which are available separately:
https://nancygold.itch.io/new-c-macroprocessor

Name: Douglas McIlroy 2022-10-29 17:07

grep -E '^[A-Fa-flLsStT]+$' words.txt
or
grep '^[A-Fa-flLsStT][A-Fa-flLsStT]*$' words.txt

And a function:

all_hex_words()
{
grep -E '^[A-Fa-flLsStT]+$' "${1}"
}

Name: Ishaan 2022-10-30 15:41

>>9
Dear Ms Nancy
Please good maam's please upload symta source code and old Nancy writtings about lua and other language please.
Good day

Name: Anonymous 2022-10-30 16:47

>>11
Hiii! I will release Symta when it is ready, because once you publish something and people write their code depending on it, it will be set in stone, and currently now I still make changes. For example, I decided to shift OOP out in favor of COP/ECS, because it allows more flexible, reusable and concise code, albeit at expense of speed, which is less important than programmer's time and mental resources.

I will leave OOP only for the system stuff, while higher level will be expected to use COP. It is just so much easier to interface with SQL databases using COP, while OOP is still nice for monolithic API modules with state, which really needs to be efficient.

Name: >>8 2022-10-31 12:19

Rewrote it to be a bit cleaner:

(defun hex-char-p (char)
(not (char/= char #\a #\b #\c #\d #\e #\f #\l #\t #\s #\o)))

(defun hex-word-p (word)
(every #'hex-char-p word))

(defun all-hex-words (words)
(remove-if-not #'hex-word-p words))


Assuming that all the words are in lowercase, and that 0 = O, 1 = L, 5 = S and 7 = T.
I wonder if sorting the characters in the call to CHAR/= by estimated frequency in dictionaries would have noticeable impact.

Name: Anonymous 2022-11-05 18:41

>>12
This is good to hear. Do you have your old git repo with your rants somewhere?

Name: Anonymous 2022-11-06 17:38

>>14
I had a github repo, but it was banned, because it had a copy of text calling Mexicans to take ICE employees families hostage and demand freedom.

Name: Anonymous 2022-11-06 17:43

>>15
That was at the time when Github became ICE subcontractor.

Name: Anonymous 2022-11-06 17:48

>>15
Could you repost it somewhere? I enjoyed your writings a lot, mostly your technical ones.

Name: Anonymous 2022-11-06 18:58

>>17
I lost most of it. Only a few snippets remained, like the bellow
IF OBJECT_ID('Pairs', 'U') IS NOT NULL
DROP TABLE Pairs
GO

CREATE TABLE Pairs
(
ID int IDENTITY(0,1) PRIMARY KEY,
CAR int,
CDR int
);
GO

IF OBJECT_ID('Symbols', 'U') IS NOT NULL
DROP TABLE Symbols
GO

CREATE TABLE Symbols
(
ID int IDENTITY(0,1) PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Value INT NOT NULL
);
GO

IF OBJECT_ID('Functions', 'U') IS NOT NULL
DROP TABLE Functions
GO

CREATE TABLE Functions
(
ID int IDENTITY(0,1) PRIMARY KEY,
SEXP INT
);
GO

CREATE UNIQUE NONCLUSTERED INDEX IX_Name ON Symbols
(
Name ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO


IF OBJECT_ID('cons', 'P') IS NOT NULL
DROP PROCEDURE cons
GO

CREATE PROCEDURE cons (@CAR INT, @CDR INT)
AS BEGIN
SET NOCOUNT ON;
DECLARE @ResultTable TABLE(Value INT)
INSERT INTO Pairs (CAR, CDR)
OUTPUT Inserted.ID INTO @ResultTable -- gets the ID of new cons-pair
VALUES (@CAR, @CDR)
RETURN (SELECT Value FROM @ResultTable)*8 + 1
END
GO

IF OBJECT_ID('uncons', 'P') IS NOT NULL
DROP PROCEDURE uncons
GO

CREATE PROCEDURE uncons (@ID INT, @CAR INT OUT, @CDR INT OUT)
AS BEGIN
SET @ID = @ID/8
SELECT @CAR = CAR, @CDR = CDR FROM Pairs WHERE ID = @ID
END
GO

IF OBJECT_ID('typeof', 'P') IS NOT NULL
DROP PROCEDURE typeof
GO

CREATE PROCEDURE typeof (@ID INT)
AS RETURN (@ID & 7)
GO

IF OBJECT_ID('reverse_list', 'P') IS NOT NULL
DROP PROCEDURE reverse_list
GO

CREATE PROCEDURE reverse_list (@Xs INT)
AS BEGIN
DECLARE @Ys INT
DECLARE @X INT
SET @Ys = 1
WHILE @Xs <> 1
BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @Ys = cons @X, @Ys
END
RETURN @Ys
END
GO

IF OBJECT_ID('intern', 'P') IS NOT NULL
DROP PROCEDURE intern
GO

CREATE PROCEDURE intern (@Name VARCHAR(255))
AS BEGIN
SET NOCOUNT ON;
DECLARE @Result INT
SELECT @Result = ID FROM Symbols WHERE Name = @Name
IF @Result IS NULL
BEGIN
DECLARE @ResultTable TABLE(Value INT)
INSERT INTO Symbols (Name, Value)
OUTPUT Inserted.ID INTO @ResultTable -- gets the ID of new symbol
VALUES (@Name, 1)
SELECT @Result=Value FROM @ResultTable
END
RETURN @Result*8 + 2
END
GO

IF OBJECT_ID('make_function', 'P') IS NOT NULL
DROP PROCEDURE make_function
GO

CREATE PROCEDURE make_function (@SEXP INT)
AS BEGIN
SET NOCOUNT ON;
DECLARE @ResultTable TABLE(Value INT)
INSERT INTO Functions (SEXP)
OUTPUT Inserted.ID INTO @ResultTable -- gets the ID of new function
VALUES (@SEXP)
RETURN (SELECT Value FROM @ResultTable)*8 + 3
END
GO


IF OBJECT_ID('function_sexp', 'P') IS NOT NULL
DROP PROCEDURE function_sexp
GO

CREATE PROCEDURE function_sexp (@ID INT)
AS BEGIN
SET @ID = @ID/8
RETURN (SELECT SEXP FROM Functions WHERE ID = @ID)
END
GO

IF OBJECT_ID('symbol_name', 'P') IS NOT NULL
DROP PROCEDURE symbol_name
GO

CREATE PROCEDURE symbol_name (@ID INT, @Name VARCHAR(255) OUT) AS
BEGIN
SET @ID = @ID/8
SELECT @Name = Name FROM Symbols WHERE ID = @ID
END
GO

IF OBJECT_ID('symbol_value', 'P') IS NOT NULL
DROP PROCEDURE symbol_value
GO

CREATE PROCEDURE symbol_value (@ID INT) AS
BEGIN
SET @ID = @ID/8
RETURN (SELECT Value FROM Symbols WHERE ID = @ID)
END
GO

IF OBJECT_ID('set_symbol_value', 'P') IS NOT NULL
DROP PROCEDURE set_symbol_value
GO

CREATE PROCEDURE set_symbol_value (@ID INT, @Value INT) AS
BEGIN
SET @ID = @ID/8
UPDATE Symbols SET Value = @Value WHERE ID = @ID
END
GO

IF OBJECT_ID('parse_number', 'P') IS NOT NULL
DROP PROCEDURE parse_number
GO

CREATE PROCEDURE parse_number (@Chars VARCHAR(64))
AS RETURN CONVERT(INT,@Chars)*8
GO

IF OBJECT_ID('print_sexp', 'P') IS NOT NULL
DROP PROCEDURE print_sexp
GO

CREATE PROCEDURE print_sexp (@SEXP INT, @Result VARCHAR(4000) OUT)
AS BEGIN
SET @Result = ''
DECLARE @Type INT
DECLARE @X INT
DECLARE @Text VARCHAR(64)
DECLARE @Tmp VARCHAR(4000)
EXEC @Type = typeof @SEXP
IF @Type = 1 -- Pair
BEGIN
SET @Result = @Result + '('
WHILE @SEXP <> 1
BEGIN
EXEC uncons @SEXP, @X OUT, @SEXP OUT
EXEC print_sexp @X, @Tmp OUT
SET @Result = @Result + @Tmp
IF @SEXP <> 1 SET @Result = @Result + ' '
END
SET @Result = @Result + ')'
END
ELSE IF @Type = 2 -- symbol
BEGIN
EXEC symbol_name @SEXP, @Text OUT
SET @Result = @Result + @Text
END
ELSE IF @Type = 0 -- number
BEGIN
SET @Result = @Result + CONVERT(INT,@SEXP/8)
END
ELSE IF @Type = 3 -- function
BEGIN
SET @Result = '#function[' + CONVERT(VARCHAR(64),@SEXP/8) + ']'
END
END
GO

IF OBJECT_ID('read_sexp', 'P') IS NOT NULL
DROP PROCEDURE read_sexp
GO

CREATE PROCEDURE read_sexp (@Cs VARCHAR(4000))
AS BEGIN
SET NOCOUNT ON
SET @Cs = REPLACE(REPLACE(@Cs,'+','$add'),'-','$sub')
DECLARE @Chars VARCHAR(64)
DECLARE @C VARCHAR(1)
DECLARE @Stack TABLE(ID INT, Value INT)
DECLARE @SP INT -- Stack Pointer
SET @SP = 0
DECLARE @X INT
DECLARE @Xs INT
SET @Xs = 1
DECLARE @I INT
SET @I = 0
DECLARE @E INT
SET @E = LEN(@Cs)
WHILE @I < @E BEGIN
SET @C = SUBSTRING(@Cs,@I+1,1)
IF PATINDEX('%[0-9a-zA-Z_$*/<>=]%', @C) = 1
BEGIN
SET @Chars = ''
WHILE PATINDEX('%[0-9a-zA-Z_$*/<>=]%', @C) = 1 AND @I < @E
BEGIN
SET @Chars = @Chars + @C
SET @I = @I + 1
SET @C = SUBSTRING(@Cs,@I+1,1)
END
IF @I <> @E SET @I = @I - 1
IF PATINDEX('%[a-zA-Z_$*/<>=]%', @Chars) = 0
BEGIN
EXEC @X = parse_number @Chars
END
ELSE
BEGIN
SET @Chars = REPLACE(REPLACE(@Chars,'$add','+'),'$sub','-')
EXEC @X = intern @Chars
END
EXEC @Xs = cons @X, @Xs
END
ELSE IF @C = '('
BEGIN
INSERT INTO @Stack VALUES (@SP, @Xs)
SET @SP = @SP + 1
SET @Xs = 1
END
ELSE IF @C = ')'
BEGIN
SET @SP = @SP - 1
SELECT @X = Value FROM @Stack WHERE ID = @SP
DELETE FROM @Stack WHERE ID = @SP
EXEC @Xs = reverse_list @Xs
EXEC @Xs = cons @Xs, @X
END
ELSE IF @C = ' ' -- ignore
DECLARE @NOP0 bit
ELSE
BEGIN
PRINT 'ERROR: Invalid char: ' + @C
END
SET @I = @I + 1
END
EXEC @Xs = reverse_list @Xs
RETURN @Xs
END
GO

IF OBJECT_ID('eval_sexp', 'P') IS NOT NULL
DROP PROCEDURE eval_sexp
GO

CREATE PROCEDURE eval_sexp (@SEXP INT)
AS BEGIN
SET NOCOUNT ON
DECLARE @Result INT
DECLARE @Type INT
DECLARE @X INT
DECLARE @Xs INT
DECLARE @A INT -- arg
DECLARE @As INT -- args
DECLARE @V INT -- value
DECLARE @Vs INT -- values
DECLARE @Body INT
DECLARE @Save INT
EXEC @Type = typeof @SEXP
IF @Type = 1 -- pair
BEGIN
IF @SEXP = 1 RETURN 1
EXEC uncons @SEXP, @X OUT, @Xs OUT
IF @X = 2 -- quote
BEGIN
EXEC uncons @Xs, @Result OUT, @Xs OUT
END
ELSE IF @X = 10 -- lambda
BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @Xs = cons 26, @Xs -- implicit progn
EXEC @Xs = cons @X, @Xs
EXEC @Result = make_function @Xs
END
ELSE IF @X = 18 -- setq
BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC uncons @Xs, @Result OUT, @Xs OUT
EXEC @Result = eval_sexp @Result
EXEC set_symbol_value @X, @Result
RETURN @Result
END
ELSE IF @X = 26 -- progn
BEGIN
SET @Result = 1
WHILE @Xs <> 1 BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @Result = eval_sexp @X
END
END
ELSE IF @X = 34 -- if
BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @Result = eval_sexp @X
EXEC uncons @Xs, @X OUT, @Xs OUT
IF @Result = 1 EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @Result = eval_sexp @X
END
ELSE -- funcall
BEGIN
SET @Vs = 1
SET @Xs = @SEXP
WHILE @Xs <> 1 BEGIN
EXEC uncons @Xs, @X OUT, @Xs OUT
EXEC @V = eval_sexp @X
EXEC @Vs = cons @V, @Vs
END
EXEC @Vs = reverse_list @Vs
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC @Result = typeof @X
IF @Result <> 3
BEGIN
PRINT 'ERROR: form head is not a function'
RETURN 1
END
IF @X = 3 -- cons
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
EXEC @Result = cons @X, @V
RETURN @Result
END
IF @X = 11 -- car
BEGIN
EXEC uncons @Vs, @V OUT, @Vs OUT
EXEC uncons @V, @Result OUT, @X OUT
RETURN @Result
END
IF @X = 19 -- cdr
BEGIN
EXEC uncons @Vs, @V OUT, @Vs OUT
EXEC uncons @V, @X OUT, @Result OUT
RETURN @Result
END
IF @X = 27 -- list
BEGIN
RETURN @Vs
END
IF @X = 35 -- +
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
RETURN @X + @V
END
IF @X = 43 -- -
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
RETURN @X - @V
END
IF @X = 51 -- *
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
RETURN @X * (@V/8)
END
IF @X = 59 -- /
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
RETURN (@X/@V)*8
END
IF @X = 67 -- =
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
IF @X = @V RETURN 0 -- return something non-NIL
RETURN 1
END
IF @X = 75 -- <
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
IF @X < @V RETURN 0 -- return something non-NIL
RETURN 1
END
IF @X = 83 -- >
BEGIN
EXEC uncons @Vs, @X OUT, @Vs OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
IF @X > @V RETURN 0 -- return something non-NIL
RETURN 1
END
EXEC @X = function_sexp @X
EXEC uncons @X, @As OUT, @Body OUT
SET @Xs = @As
SET @Save = 1
WHILE @As <> 1 BEGIN -- setup environment
EXEC uncons @As, @A OUT, @As OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
EXEC @X = symbol_value @A
EXEC @Save = cons @X, @Save
EXEC set_symbol_value @A, @V
END
EXEC @Result = eval_sexp @Body
EXEC @Vs = reverse_list @Save
WHILE @As <> 1 BEGIN -- restore environment
EXEC uncons @As, @A OUT, @As OUT
EXEC uncons @Vs, @V OUT, @Vs OUT
EXEC set_symbol_value @A, @V
END
END
END
ELSE IF @Type = 2 -- symbol
BEGIN
EXEC @Result = symbol_value @SEXP
END
ELSE IF @Type = 0 -- number
BEGIN
SET @Result = @SEXP
END
RETURN @Result
END
GO

IF OBJECT_ID('eval', 'P') IS NOT NULL
DROP PROCEDURE eval
GO


CREATE PROCEDURE eval (@Cs VARCHAR(4000))
AS BEGIN
DECLARE @Result INT
EXEC @Result = read_sexp @Cs
EXEC @Result = cons 26, @Result -- implicit progn
EXEC @Result = eval_sexp @Result
RETURN @Result
END
GO


EXEC cons 1, 1 -- NIL
GO

-- Pre-Intern standard symbols, so the get following values
EXEC intern 'quote' -- 2
EXEC intern 'lambda' -- 10
EXEC intern 'setq' -- 18
EXEC intern 'progn' -- 26
EXEC intern 'if' -- 34
GO

-- builtin functions stubs
exec eval '(setq cons (lambda () ))'
exec eval '(setq car (lambda () ))'
exec eval '(setq cdr (lambda () ))'
exec eval '(setq list (lambda () ))'
exec eval '(setq + (lambda () ))'
exec eval '(setq - (lambda () ))'
exec eval '(setq * (lambda () ))'
exec eval '(setq / (lambda () ))'
exec eval '(setq = (lambda () ))'
exec eval '(setq < (lambda () ))'
exec eval '(setq > (lambda () ))'
GO

-- predefined functions
exec eval '(setq map (lambda (_f _xs) (if _xs (cons (_f (car _xs)) (map _f (cdr _xs))))))'
exec eval '(setq fac (lambda (n) (if (< n 1) 1 (* n (fac (- n 1))))))'

DECLARE @Text VARCHAR(4000)
DECLARE @Result INT
exec @Result = eval '(fac 5)'
exec print_sexp @Result, @Text OUT
PRINT @Text

exec @Result = eval '(map (lambda (x) (* x x)) (list 1 2 3 4 5))'
exec print_sexp @Result, @Text OUT
PRINT @Text

Name: Corey Simpson 2022-11-09 6:20

>>18
Oi this looks like Xcode.

Name: Anonymous 2022-11-09 9:54

>>19
that is mssql

Name: Anonymous 2022-11-09 17:01

>>18
IF OBJECT_ID('Pairs', 'U') IS NOT NULL
DROP TABLE Pairs
GO
Unbelievable that it's how you write it

Name: Anonymous 2022-11-09 22:49

>>21
Shared nothing architecture.

Name: Corey Simpson 2022-11-10 0:34

>>20
*takes a gigantic shit on your non-apple-friendly programming language*

Name: Anonymous 2022-11-10 2:29

0x80081355

Name: Anonymous 2022-11-10 10:27

>>24
but ik heb boobies!!!!11

Name: Anonymous 2022-11-10 15:05

>>23
the only good Apple was the Apple II

Name: Anonymous 2022-11-10 15:50

>>25
ga terug naar rusland en krijg de tering

Name: Anonymous 2022-11-10 20:17

>>27

pedo!

Name: Anonymous 2022-11-10 23:02

>>28
BY THE POWER OF DOMINATION LAWS I HEREBY SHOVE NANCY GOLD'S TOELESS FOOT UP YOUR BACKSIDE

Name: Anonymous 2022-11-12 19:42

the golden bone foot of the toeless lich

Name: Steve Jobs 2022-11-14 4:55

>>26
the only good Apple was the Apple II

That's Apple ][ ain't it?

Name: Anonymous 2022-11-16 21:17

>>31
Sure, also how is your case of ligma doing, I heard you died

Name: Anonymous 2022-11-16 23:59

It turned into sigma. I quite like it better now

Name: Anonymous 2022-11-17 12:03

Sigma, ligma, bigma balls

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