157 points · by jsnell · 10y ago · 38 comments
Keyword: program synthesis
[0]: http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.ht...
I imagine this would be much easier to implement in a language with strong typing since the vast majority of possible matches could be ruled out with a simple signature check instead of evaluation.
Having a feature like this would be very useful when teaching people how to program since it would help answer a lot of the basic questions that get asked.
You could use the p-adic norm. But that will probably not be the right notion for most applications.
This searches through a list of predefined (built-in?) functions and finds one that can match the given inputs and outputs. That sounds pretty cool and rather handy and although it's a form of machine learning (or function approximation in any case) it's not trying to sell itself off as anything it isn't, which was my initial concern. My bad for overreacting.
;; Inputs (one per line):
'(a b c d)
;; Desired output:
'(1 2 3 4)
;; Suggestions:
;; No matches found.
Damn :( ;; Inputs (one per line):
'(a b c d)
;; Desired output:
'(a b)
;; Suggestions:
;; No matches found.In terms of computational cost, this makes sense: removing the last element of a list in lisp takes linear time with the size of the list, while removing the first element takes constant time. (If you're returning a copy this is moot, but if you're modifying in-place this could be a problem.)
"I'll pass your feedback on to the devs" by any other name would sound as sweet.
Similarly for pseudocode rather than only ins/outs.
Maybe code analysis for similar implementations to (or optimizations of) what you're in the middle of developing.
Have long wondered about this, but never got around to dinking with it at all. Cool to see things along these lines.
Go back to your cubicle, grab a piece of paper, clarify your thoughts, describe what you want in the general case, provide at least 3 examples, possibly more of there are lots of tricky corner cases. And only then come back. Thanks.