# Suggest.el: Synthesising Constants

DevFeed: [Suggest.el: Synthesising Constants](<https://devfeed.tech/articles/suggest-el-synthesising-constants-22017.md>)

Original publisher: [Read original article](<http://www.wilfred.me.uk/blog/2017/08/06/suggest-el-synthesising-constants/>)

Author: Wilfred Hughes

Published: 2017-08-06T00:00:00Z

Content type: release

Language: en

Sources: [Wilfred Hughes](<https://devfeed.tech/sources/wilfred-hughes.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [bug](<https://devfeed.tech/topics/bug.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [code](<https://devfeed.tech/tags/code.md>)

## AI overview

Suggest.el v0.4 adds constant synthesis, improves suggestion ranking, searches intermediate values more efficiently, and documents related projects. It also expands the operations the tool can discover.

## Source excerpt

Suggest.el v0.4 is now out, and it offers some really interesting new ways of making suggestions. Supplying Constants Suppose the user gives us the input '(a b c d) and desired output 'a. We would already suggest car, but that only gets the first element of the list. They may have wanted elt or nth, which get elements at a specific position. We now try adding constants to the user's inputs, specifically nil, t, -1, 0, 1 and 2. This makes suggest.el much more effective. Here's the example we mentioned: ;; Inputs (one per line): '(a b c d) ;; Desired output: 'a ;; Suggestions: (car '(a b c d)) (elt '(a b c d) 0) ; <- new (nth 0 '(a b c d)) ; <- new We can now suggest grouping items in a list pairwise: ;; Inputs (one per line): '(a b c d e f) ;; Desired output: '((a b) (c d) (e f)) ;; Suggestions: (-partition 2 '(a b c d e f)) ; <- new Converting a vector to a list: ;; Inputs (one per line): (vector 1 2 3) ;; Desired output: (list 1 2 3) ;; Suggestions: (string-to-list (vector 1 2 3)) (append (vector 1 2 3) nil) ; <- new (-rotate 0 (vector 1 2 3)) ; <- new (-concat (vector 1 2 3) nil) ; <- new Truncating lists: ;; Inputs (one per line): '(a b c d e) ;; Desired output: '(c d e) ;; Suggestions: (-drop 2 '(a b c d e)) ; <- new (-slice '(a b c d e) 2) ; <- new (cdr (cdr '(a b c d e))) Choosing good values for constants is difficult, but the current set seems to be a good tradeoff between performance, the likelihood of finding a result, and the number of useful results. Ranking Suggestions Now we have more possibilities, ordering our suggestions is more complex. The first prototype didn't always get the ordering correct: ;; Inputs (one per line): 0 ;; Desired output: 1 ;; Suggestions: (+ 0 1) ; <- new (- 1 0) ; <- new (1+ 0) The user is probably looking for the increment function, 1+. (+ 0 1) feels like stating the obvious. Suggest.el prefers function calls that don't require extra arguments, giving us a better order: ;; Inputs (one per line): 0 ;; Desired output: 1 ;; Sugg