I have often felt that one of the real problems facing The New School is a lack of unified and consistent vision. The ability to reference and be guided by some manner of underlying philosophical foundations would greatly increase the school's governmental and communal stability. However, as of yet (and perhaps owing to the school's democratic nature and ever-changing populace), the philosophical waters of the school are at present murky and unexplored.
A prime embodiment of the consequences of this inconsistent and unexamined philosophical bedrock can be found in the school's "Gateway" policy. Gateways were concocted and implemented – without authorization from the student body or parents - by the school faculty as a means of testing student learning and conceptual understanding. This was a noble goal, to be sure: there was widespread fear that students were graduating from the New School without having mastered key concepts in math, science, and English language. I was a sort of "guinea pig" for the gateway program, being the first to attempt (and pass) the mathematics and "persuasive essay" gateways. In doing so, I had to demonstrate my abilities in both categories as measured against a rubric which had been devised by the teachers. This brings me to my first concern: creating standardized tests is a difficult task. It would seem to me that there are two criteria which a standardized test should attempt to pass:
1. Doing well on the test necessitates knowledge and understanding of the subject matter.Designing a test which adheres to both these principles is not only hard, but perhaps even impossible. A test which caters to all methods of expressing subject mastery will expose itself to methods of expression which do not demonstrate learning, but are so abstract or subjective in evaluation as to be indistinguishable from those that do. On the other hand, a test which cannot in any case be "fooled" by such methods of expression and ensures that the test-taker have complete understanding of the subject matter will be so strict as to filter out those who have sufficient understanding but are not compatible with the test's methods of evaluation.
2. Understanding the subject matter guarantees that one does well on the test.
A while ago, a friend of mine who was unfamiliar with python asked me how to go about parsing a CSV into a list of lists. Moreover, the data included integers which needed to be parsed as such (and not as strings). My solution was as follows:
(lambda f: [map((lambda x: x.isdigit() and int(x) or x),(line.split(','))) for line in f.readlines()]) #takes a fileJust yesterday, another friend of mine had accidentally merged and subsequently sorted two excel spreadsheets, and overwrote one with the result. She asked if I could take the merged file and the remaining original file and re-construct the file she had overwritten. Incorporating the CSV parsing function I had written earlier, I wrote this:
from tkFileDialog import asksaveasfile, askopenfile full = (lambda f: [map((lambda x: x.isdigit() and int(x) or x),(line.split(','))) for line in f.readlines()])(askopenfile()) exclude = (lambda f: [map((lambda x: x.isdigit() and int(x) or x),(line.split(','))) for line in f.readlines()])(askopenfile()) (lambda f: map(f.write,(map(','.join,filter((lambda x: x not in exclude),full)))))(asksaveasfile())Tags: code, csv, filter, lambda, map, programming, python, tkinter
More functional programming fun.
(lambda l: max([(l.count(i), i) for i in set(l)]))Tags: lambda, math, programming, python, statistics, code
You can hardly even tell that I took a course on functional programming last semester.
import turtle eq = "(x ** 2) / 1.5" map((lambda x: turtle.setx(x) or turtle.sety(x)),[(n,(eval(eq.replace("x","(" + str(n) + ")")))) for n in range(0,100)])Tags: code, lambda, math, programming, python
Recently, I was reading about some sample interview questions used (at some point) by Google. One such question was "what are the first 10 consecutive digits of e that form a prime number?" Curious, I went to Wikipedia and looked up some primality tests that I could run on 10-digit prime candidates (if you'll forgive the pun) from e. One such test was Fermat's Primality Test, which can be used to probabilistically assess a number's primality (it fails on Carmichael numbers, et alia). I've written up a short python script which runs the test on the numbers 1 to 100 using computed probable primes as possible coprimes and returns all probable primes.
def test(end): candidates = range(1,end+1) primes = list() for candidate in candidates: prime = True for prime in primes: if candidate % prime: test_result = ((prime ** (candidate - 1)) % candidate) print "Candidate: %s, Prime: %s, Result:%s" %(candidate,prime,test_result) if test_result != 1: prime = False break if prime: primes.append(candidate) return primes test(100)