1) With many of these functions, there's usually an imaginary preposition 
there, when I read most of them functions:

sort ls by >
cons X onto ls
remove X from ls
map f over ls

2) Any "-ref" function — list-ref, vector-ref, hash-ref — has the object first. 
Longstanding Scheme/lisp convention, and it resembles array/object 
dereferencing in C-style languages.

3) Most of the higher-order list functions — folds, maps, and filters — take 
the function first and the list last.

4) The only ones that trip me up repeatedly are the take and drop family of 
functions. Putting the list first clashes with the obvious (to me) 
imaginary-preposition reading — "take n from ls" is wrong, as you said — and 
also is opposite to how Haskell does it (and Haskell is where I first used take 
and drop). Otherwise, they've all seemed intuitive to me.

Best,
Jordan

> On Apr 21, 2016, at 3:04 AM, Daniel Prager <daniel.a.pra...@gmail.com> wrote:
> 
> Does anyone else struggle to remember the order of arguments for some of the 
> common functions?
> 
> There seem to be two extant conventions, roughly:
> object-first: (function obj other)
> object-last: (function other obj): e.g.
> Object-first: take, drop, list-ref, add-between, sort
> Object-last: cons, member, remove, map, filter, foldl, foldr
> 
> (remove v lst) means "remove the first instance of v from lst" and reads ok..
> 
> OTOH (take lst n) means "take the first n items from lst", which occasionally 
> trips me up, possibly guided by the flipped order in the English 
> interpretation.
> 
> Am I missing some sort of principal or mnemonic?
> 
> How do others cope? Do you make heavy use of the "blue box" in DrRacket?
> 
> Dan
>  
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to