Re: Lambda in parameters

2020-12-19 Thread Abdur-Rahmaan Janhangeer
Greetings list, Jane Street is well known for its love of functional programming in general and of OCaml in particular. If you don't know OCaml yet, I highly recommend it. You can think of it as Python with (static) types. Yes i know OCaml when i was exploring haskell and the like. At that

Re: Lambda in parameters

2020-12-19 Thread Abdur-Rahmaan Janhangeer
Greetings list, Why car and cdr? Well obviously car is content of the address register and cdr is content of data register. Apparently an artefact of a early implementation of lisp. Oh did not know that detail. More twists for sure. Thought lisp did not go lowlevel. Kind Regards,

Re: Lambda in parameters

2020-12-19 Thread Abdur-Rahmaan Janhangeer
Greetings, Very clear explanations, rewriting lambdas as a function was the key to understand it. Did not know was a lisp inspiration. My mind still spiralling XD Kind Regards, Abdur-Rahmaan Janhangeer about | blog github

Re: Lambda in parameters

2020-12-19 Thread Greg Ewing
On 18/12/20 7:02 pm, Cameron Simpson wrote: Frankly, I think this is a terrible way to solve this problem, whatever the problem was supposed to be - that is not clear. It demonstrates that a programming language doesn't strictly need data structes -- you can do everything with nothing but

Re: Lambda in parameters

2020-12-19 Thread Cameron Simpson
On 19Dec2020 07:39, Philippe Meunier wrote: >See also the example reduction >here: https://en.wikipedia.org/wiki/Church_encoding#Church_pairs Thank you for this reference. I've stuck it on my reading list. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Lambda in parameters

2020-12-19 Thread Philippe Meunier
Abdur-Rahmaan Janhangeer wrote: >The aim of car is to return 1 >but i don't understand how lambda achieves this Cameron Simpson's explanation is very good. See also the example reduction here: https://en.wikipedia.org/wiki/Church_encoding#Church_pairs >This problem was asked by Jane Street.

Re: Lambda in parameters

2020-12-18 Thread Grant Edwards
On 2020-12-18, Barry wrote: >> Implement car and cdr. > Why car and cdr? > > Well obviously car is content of the address register and cdr is content of > data register. > Apparently an artefact of a early implementation of lisp. While car and cdr are lisp operators, the "content of address

Re: Lambda in parameters

2020-12-18 Thread Julio Di Egidio
On Friday, 18 December 2020 at 15:20:59 UTC+1, Abdur-Rahmaan Janhangeer wrote: > The Question: > > # --- > This problem was asked by Jane Street. > > cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first > and last element of that pair. For example, car(cons(3, 4))

Re: Lambda in parameters

2020-12-18 Thread Barry
> On 18 Dec 2020, at 14:23, Abdur-Rahmaan Janhangeer > wrote: > > The Question: > > # --- > This problem was asked by Jane Street. > > cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first > and last element of that pair. For example, car(cons(3, 4)) returns 3, and >

Re: Lambda in parameters

2020-12-18 Thread Abdur-Rahmaan Janhangeer
The Question: # --- This problem was asked by Jane Street. cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4. Given this implementation of cons: def cons(a, b):

Re: Lambda in parameters

2020-12-17 Thread Cameron Simpson
On 17Dec2020 23:52, Abdur-Rahmaan Janhangeer wrote: >Here is a famous question's solution These look like implementations of Lisp operators, which I've never found easy to remember. So I'll do this from first principles, but looking at the (uncommented) code. This is some gratuitiously tricky