Arithmetic Sequences

Non-golfed haskell, 32

f a n t=takeWhile(<=t)[a,a+n..]

I'd love to change takeWhile to take, but integer division can't be done with /, it needs to be done with div. If I go with / then I need to do implicit conversion which makes it that much longer.


J, 34 33 31 characters

({.+i.@>:@([:<.1{[%~{:-{.)*1{[)

I'm sure there's room for improvement here.

Usage:

   ({.+i.@>:@([:<.1{[%~{:-{.)*1{[)2 3 10
2 5 8

We can give the verb a name for an extra three characters:

   s=.({.+i.@>:@([:<.1{[%~{:-{.)*1{[)
   s 2 3 10
2 5 8

Previously:

((0-.~]*]<:2{[)(((i.100)*1{[)+{.))

Thought I'd have a go at doing this in Golfscript and got as far as .3$- 2$/1+,{2$*}%{3$+}% before realising Golfscript doesn't seem to do floats. Bugger.


APL (22)

{⍵≤T:⍵,∇⍵+N⋄⍬}⊃A N T←⎕

Reads input from stdin as three whitespace-separated numbers.

This is actually shorter than using the index generator.