Wednesday, October 1, 2014

Friday, September 26, 2014

J and Python Tips

J
$: self reference for recursion etc.
Have to experiment with it

Python
seq[:1] and seq[-1:] first and last without index fail for empty sequences
Generically for all except last as seq[n:n+1] instead of seq[n]

Saturday, March 22, 2014

j

What a difference a month of using an APL language variant, A Programming Language. I learned a bit more about ipython and the %%script cell command when I started playing with j in a ipython notebook. It seems like I can get by a problem at a time writing scripts in j and running  them and organizing them in an ipython notebook. I have been able to one up ipython by working in j-console and using Droidedit on my Android and Textpad on my iPad Mini.
Developing on my phone in J using the j-console app for Android has changed my mind about going much further down the path of an expanded language learning and improvement experiment. I've decided to stick to perfecting my j skills for the foreseeable future. J's super optimized algorithms and terse formulaic functional programming is exactly what I was looking for in a programing language.
I came to this realization after I reimplemented the first few problems from projecteuler.net in j.
For more check out the history of APL

Edit. oops, forgot to finish this post. I am now a half year into my j language learnings and have finished the first 17 problems in order at http://projecteuler.net

Go checkout j for yourself. The primer is the fastest way to get competent in j. http://jsoftware.com

Here is a search and replace I put together after talking about examining the efficiency and correctness/completenes/wordiness of the search and replace in the standard library for j. Next step profile this against the standard library verb and actually read through the code and add any missing features.

rep.ijs

NB. rep file contains srep verb
NB. original working concept
; 'xyz'&, each (#'abc')&}. each(('abc' E. 'abcdefabcghi') <;. 1 'abcdefabcghi')
NB. srep verb
srep =: 4 : '; (> {:x)&, each (#>{.x)&}. each ((>{.x) E. y) <;. 1 y'
smoutput 'example usage (''abc'';''xyz'') srep ''abc123abc456'''

smoutput ('abc';'xyz') srep 'abc123abc456'