Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #52780 > unrolled thread
| Started by | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| First post | 2016-11-21 00:16 +0000 |
| Last post | 2016-11-21 00:16 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.forth
:Re: A simple lisp problem. "Robert L." <No_spamming@noWhere_7073.org> - 2016-11-21 00:16 +0000
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2016-11-21 00:16 +0000 |
| Subject | :Re: A simple lisp problem. |
| Message-ID | <o0tecm$1ora$1@gioia.aioe.org> |
Frank Schwieterman wrote:
> >I am Lisp beginner and I am doing a simple execise on lisp. I was asked
> >to write a lisp program , by using either recursion or do, to return
> >true if the difference between each successive pair of the them is 1.
> >
> >ie:
> >
> >>(difference '(2 1))
> >T
> >>(difference'(3 4 5 6 5 4))
> >T
> >>(differnce '(3 4 5 3))
> >NIL
....
>
> (defun difference (param)
> (if (> (length param) 1)
> (if (<= (abs (- (first param) (first (rest param)))) 1 )
> (difference (rest param))
> nil
> )
> T
> )
> )
Ruby:
def diff1 array
array.each_cons(2).all?{|a,b| 1 == (a-b).abs}
end
diff1 [2,1]
==>true
diff1 [3,4,5,6,5,4]
==>true
diff1 [3,4,5,3]
==>false
In Forth?
--
Again, commenters focused on the double standard whereby Jews advocate
multiculturalism and immigration for Europe, but have Israel as an avowedly
Jewish state to fall back on....
theoccidentalobserver.net/2015/11/douglas-murrays-warning-to-the-jewish-community
Back to top | Article view | comp.lang.forth
csiph-web