Re: some array functions

124 views
Skip to first unread message

Mark Tarver

unread,
May 22, 2013, 6:33:27 AM5/22/13
to Qilang
Its in github coded by Eric, but not in standard lib. Mainly when you
need a missing list function you can either look for it in lib or
write 3 lines of code. Mostly I just write the code. I think if we
had an IDE which allowed people to find this stuff it would encourage
use. But I expect most people would still roll their own.

Mark

On 21 May, 16:38, Jacob <submissionfight...@gmx.com> wrote:
> There is a standard lib that has such fns.
>
>
>
>
>
>
>
> On Tuesday, May 21, 2013 4:17:00 AM UTC-4, newbie wrote:
>
> > (define it0
> >      N -> (it N []))
>
> > (define it
> >     0 L -> L
> >     N L -> (it (- N 1) (cons (- N 1) L)))
>
> > (define timesL
> >    _ [] -> []
> >    [X|Y] [P|Q] -> (cons (* X P) (timesL Y Q)))
>
> > (define addL
> >    _ [] -> []
> >    [X|Y] [P|Q] -> (cons (+ X P) (addL Y Q)))
>
> > (define add0
> >     [] N -> N
> >    [X|Y] N -> (add0 Y (+ N X)))
>
> > (define adds
> >      L -> (add0 L 0))
>
> > (define take
> >    0 _ -> []
> >    N [X|Y] -> [X|(take (- N 1) Y)])
>
> > (define drop
> >       0 L -> L
> >     N [X|Y] -> (drop (- N 1) Y))
>
> > (define fromto
> >     N M L -> (take (- M N) (drop N L)))
>
> > (define abs
> >    N -> (* N -1) where (< N 0)
> >    N -> N)
>
> > (define dropflast
> >    N L -> (take (- (length L) (abs N)) L))
>
> > (define droplast
> >       [] -> []
> >      [A] -> A
> >    [X|Y] -> (if (not (= (tail Y) [])) (droplast Y) (head Y)))
>
> > (define from
> >    0 L -> (head L)
> >    N [X|Y] -> (from (- N 1) Y))
>
> > (define fromp
> >    [] _ -> []
> >    [X|Y] L ->  (cons (from X L) (fromp Y L)))
>
> > (define amend
> >     N M L -> (append (take N L) (cons M (drop (+ N 1) L))))
>
> > (define tie
> >         _ 0 -> []
> >         L N -> (append L (tie L (- N 1))))
>
> > (define makearray1
> >        0 N L -> (append (reverse N) [L])
> >        M N L -> (if (< M (length L)) (makearray1 M (cons (take M L) N)
> > (drop M L))
> >                   (makearray1 0 N L)))
>
> > (define makearray
> >         M L -> (makearray1 M [] L))
>
> > (define k -> (makearray 10 (makearray 10 (it0 200))))
>
> > (define q -> (tie (k) 5))
>
> > (define r -> (tie (q) 3))
>
> > \* (it0 20) *\
>
> > \* (addL (it0 20) (it0 20)) *\
>
> > \* (adds (it0 100)) *\
>
> > \* (take 5 (it0 20)) *\
>
> > \* (drop 5 (it0 20)) *\
>
> > \* (fromto 5 10 (it0 20)) *\
>
> > \* (dropflast 2 (it0 10)) *\
>
> > \* (droplast (it0 10)) *\
>
> > \* (fromp [2 3 1] [a b c d e]) *\
>
> > \* (amend 2 a [1 2 3 4]) *\
>
> > \* (makearray 5 (it0 20)) *\
>
> > \* (k) *\
>
> > \* (q) *\
>
> > \* (r) *\

Konrad Hinsen

unread,
May 23, 2013, 2:50:13 PM5/23/13
to qil...@googlegroups.com
Mark Tarver writes:

> Its in github coded by Eric, but not in standard lib. Mainly when you
> need a missing list function you can either look for it in lib or
> write 3 lines of code. Mostly I just write the code. I think if we
> had an IDE which allowed people to find this stuff it would encourage
> use. But I expect most people would still roll their own.

If you write code just for your own pleasure, that may indeed be the
lesser effort. But if you work in a team, it pays off to use standard
names and signatures for frequently used functions. And if you count
on recruiting new members for your team easily, it pays off to use a
language where all that is in a standard library, meaning that the
whole language community agrees on the names and signatures and people
can easily read each other's code.

This has traditionally been one of the problems of Lisp: it's so easy
to make one's own sublanguage that it becomes a lot of work to understand
someone else's code.

Konrad.

Mark Tarver

unread,
May 25, 2013, 1:19:53 AM5/25/13
to Qilang
The main reason why most github stuff has not got into standard lib is
the lack of documentation. Willi did a superb job for the maths
library and really if people just wrote a few pages of pdf to go with
their code I'd be pleased to put it up.

Mark

On 23 May, 23:08, Artella Coding <artella.cod...@googlemail.com>
wrote:
> Github location :https://github.com/vasil-sd/shen-libs

Mark Tarver

unread,
May 25, 2013, 3:21:53 AM5/25/13
to Qilang
If you have Word, you can save it as a pdf file. Maybe Open Office
can do the same.

Mark

On 25 May, 06:31, newbie <swtchwrd...@gmail.com> wrote:
> I never looked at github on Shen homepage until Jacob mentioned about it
> yesterday.
> I always thought it was for serious developers transliterating to Shen
> phenotype platforms
> full of complex codes. (had to look up genotype vs. phenotype on online
> dictionary, I got
> confused and didn't want to get it incorrect, and I would have)
> I don't know how to make pdf files, but I prefer to comment with simple
> examples for any
> functions that do not appear obvious as to its purpose at first glance.

Mark Tarver

unread,
May 25, 2013, 3:49:55 AM5/25/13
to Qilang
If you are building something on top of Shen, it can be under any
license you like. Unlike the GPL, the Shen license is not viral.
Indeed it cannot be because the spec is defined just for the kernel.
As long as the kernel is respected, and any changes do not lose
functionality, it's fine. I don't see any reason why your project
needs to change that.

Its hard to place a Shen-style license on a piece of software unless
you have a clear and written spec for your work. I'd suggest placing
it under BSD. If at some later stage you feel that the work has
matured to the point where the salient features are fixed you could
place it under a Shen-style license.

I'd suggest looking at Codd's relational algebra for the primitives of
your system. CRA is the basis for languages like SQL and RDBMS in
general.

Mark

On 25 May, 07:12, newbie <swtchwrd...@gmail.com> wrote:
> I hope this isn't too much of posting but I wanted to add that...
>
> I want to release Shena 0.1 under the Shen License but I don't know how.
> Whereas with BSD license it seems that one only has to explain or declare
> that such and such is being released with BSD license, Shen license itself
> seems to designate Dr. Tarver as the copyright holder, does that hold for
> only
> Shen language itself, or anything that is released under Shen license? I
> don't know.
>
> Maybe this is an obvious and primitive point, but I'm just unsure...
>
> If possible, I would like to release Shena 0.1 under the Shen License first
> and foremost
> and where, if any,  Shen License does not apply, I would like Shena 0.1 to
> follow the BSD License.
> And where there is doubt, I want Shen License to prevail... but provided
> that I remain as
> the copyright holder in so far as copyright law applies.
>
> Anyway, to highlight some of what Shena 0.1 entails (in hopes that someone
> will have created same
> functions in time before the release of Shena 0.1 thereby making it a moot
> point so we can work on more
> noble aspects of Shena paradigm):
>
> "take" function is now tail-recursive (finally!)
> explicit example of the power of "amend" function that can a list of a list
> of a list of a list... as an argument for
> the amend function to take on (obvious point, I'm sure, but it's nice to
> see it as an example, to me)
> explicitly commenting how the makearray function in conjunction with tie
> function is capable of creating a singular,
> continuous, and contiguous database capable of holding hundreds of billions
> of data but with a caveat that doing so can make the system go unstable and
> prone to stack overflow (even with tail recursion, I suspect), and offering
> a better alternative that isn't so resource-hungry and still can produce
> reliable results for a query of the same or even bigger-sized
> databse) -- solution is so simple that it would be laughable if not for the
> fact that it works (for some queries, though not all) as designed (thanks
> to Shen)
> also... things like, how you can take a matrix and amend (replace) a row or
> a column with a new row or column, and
> add a new row or column inside the matrix, or at the top, bottom, sides,
> and also call out a diagonal matrix from any point
> on the matrix, not just the main center diagonal line, etc... some sorting
> functions, sorting up and sorting down... some permutation function...
> ceiling and floor function... I'm sure someone has already figured this out
> and will post which will be good because then we can move on to Shena 0.2
>
> Thank you.

Mark Tarver

unread,
May 25, 2013, 2:26:49 PM5/25/13
to Qilang
Codd's relational algebra is > 40 years old. You won't fall foul of
any copyright.

Mark

On 25 May, 18:14, newbie <swtchwrd...@gmail.com> wrote:
> I think I will stick to functions I made out of my own needs, or functions
> I made using clean room method where I only looked at the function's
> behavior and made my own out of that information. I don't know enough about
> copyright laws to feel comfortable with posting functions whose algorithm
> steps I followed from a book, for instance.
> So it won't be much more than what my last post of array functions was, but
> I hope it will be helpful.
Reply all
Reply to author
Forward
0 new messages