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

Text parsing

Name: Anonymous 2014-04-16 11:26

Hey guys suppose I have an application that is fed the body of my post. Now my post might contain quotations such as
>>8
>>3-7
>>2,3,4
>>7-8,2,5,10-12
It also may have quotations mid-text such as >>42.

Now, I want the result of my application to be
2 3 4 5 6 7 8 10 11 12
.
Notice 42 is missing because it was midtext.

How would you code that? (Before you laugh and say it's trivial - it is, but I want to code it).

I figured, maybe I will use perl. But maybe not. Since it's been a lot of time since I coded, I want to use something that is funky to code it. Perhaps factor, or J. Well, that's my shitty thread, thanks for reading.

Name: Anonymous 2014-04-16 12:17

http://www.jsoftware.com/help/primer/j_list_adding.htm
Years of research and thought have gone into how J verbs work with lists. For example, if you wanted to add 1 to each number in a list.

1 + 2 3 4
3 4 5

It just checks if one of the lists has unit length. "Years of thought".

Name: Anonymous 2014-04-16 12:20

>>3
K I was wrong. It actually is some sort of type checking beforehand.

Name: Anonymous 2014-04-16 12:47

Here's the monte carlo method of estimating pi in J gentlemen.

foo =: monad : 0
4*(+/((?y$0^2)+(?y$0^2))<1)%y
)

Although it doesn't fucking work! Maybe the PRNG sucks. I also don't like the number of parentheses I had to use and the fact I repeated the y argument so many times. I wonder how these can be eliminated from the code.

Name: Anonymous 2014-04-16 12:56

>>5
btw in pseudo common lisp this would be

(defun estimate-pi (n) ; number of points n to use for the method
(/ (count (\. (x) (< x 1))
(mapc +
(split-in-half ; splits (a b c d) to ((a b) (c d))
(mapcar (\. (x) (^ x 2))
(randlist (* 2 n))))) ; a list of length 2n of [0,1] random doubles.
n 0.25)

I'm only posting this so that you can see how shitty the algorithm that I used in the >>5 post is, if you don't know J.

Name: Anonymous 2014-04-16 20:45

Bump for code.

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