0 Members and 1 Guest are viewing this topic.
So, is this just going to never be in the new "Tutorials" section? I've asked like 5 times in 3 separate threads, and I'm pretty much forced to give up all hope. People who want to see this will have to follow the new "this is outdated link" in the old tutorial, I guess
Quote from: Ashbad on July 28, 2011, 09:33:52 pmSo, is this just going to never be in the new "Tutorials" section? I've asked like 5 times in 3 separate threads, and I'm pretty much forced to give up all hope. People who want to see this will have to follow the new "this is outdated link" in the old tutorial, I guess Nope, you can add it now. If you'd like, I can add it for you. Just let me know.
Quote from: ztrumpet on July 28, 2011, 09:55:39 pmQuote from: Ashbad on July 28, 2011, 09:33:52 pmSo, is this just going to never be in the new "Tutorials" section? I've asked like 5 times in 3 separate threads, and I'm pretty much forced to give up all hope. People who want to see this will have to follow the new "this is outdated link" in the old tutorial, I guess Nope, you can add it now. If you'd like, I can add it for you. Just let me know. orly?I didn't know I could add this.. Sorry for the bitching
.ITERATEIter()→LDisp (L)()►Dec,iDisp (L)()►Dec,iDisp (L)()►Dec,iIter()→MDisp (M)()►Dec,iDisp (M)()►Dec,iDisp (L)()►Dec,iLbl IterReturnλ( λ( λ( r₁+1→r₁ ) )(0))()
asm(prgmITERATE 1 2 3 1 2 4
.ITERATEIter(10)→LDisp (L)()►Dec,iDisp (L)()►Dec,iDisp (L)()►Dec,iLbl IterReturnλ( λ( λ( r₁+1→r₁ ) )(r₁))()
asm(prgmITERATE 11 12 13
Hey guys, I was really impressed by these new features of Axe, so I decided to register to make this post! I figured we could use a non-trivial example of how lambdas can be actually used.This is an example of some functional code that we wrote in one of my programming classes. The objective was to write a function that creates iterators. Each time you call the iterator, it returns one more than the previous call. We do this with lambda syntax and closures. We wrote this in Scheme, but I was surprised and impressed to see it correctly execute in Axe.The Axe code:(I used liberal amounts of spaces to get it to line up the way I did)Code: [Select].ITERATEIter()→LDisp (L)()►Dec,iDisp (L)()►Dec,iDisp (L)()►Dec,iIter()→MDisp (M)()►Dec,iDisp (M)()►Dec,iDisp (L)()►Dec,iLbl IterReturnλ( λ( λ( r₁+1→r₁ ) )(0))()Output:Code: [Select]asm(prgmITERATE 1 2 3 1 2 4An interesting side-effect of this is that the current iteration is not stored in any variables - it's captured in the closure. Not that it's efficient to do this on a calculator with limited memory, but...
Subroutine arguments, as in sub(LBL,1,2,3) calls LBL with 1 in r1, 2 in r2, and 3 in r3.
a subroutine argument is a value you give to a subroutine.