Lol, he uses the word ``Cardinality'' instead of ``length'' to sound less retarded. Also, shitty snippets written by lamers in his terminology are ``small algorithms''.
The program is supposed to pick a string from an array of pointers to chars, but allow the program to include more words in the array if just typed in the declaration and recompiled. It uses the rand() function to pick a word from the array, which the program then concatenates to other randomly picked words to form a sentence. The problem I am having is I need to dynamically determine the number of elements in the array in order to use the modulus to pick the random word. Here is some of my code:
The programissupposedto pick astringfroman array ofpointerstochars, but allowtheprogramto include morewordsinthe array ifjusttypedin the declarationandrecompiled.It uses therand()functionto pick awordfromthe array, whichtheprogramthen concatenates tootherrandomlypicked words toformasentence. The problemIamhaving is Ineedtodynamically determine thenumberofelements in thearrayinorder to usethemodulusto pick therandomword.Here is someofmycode
Name:
Anonymous2009-05-23 18:18
Prelude> let bbcode indice text = "["++indice++"]"++text++"[/"++indice++"]"
Prelude> let b = bbcode "b"
Prelude> let u = bbcode "u"
Prelude> let i = bbcode "i"
Prelude> let expert = b . u . i
Prelude> expert "programmer"
"programmer"
Prelude> zipWith ($) (cycle [id, b, u, i, expert]) (words s)
* Exception: Stack overflow
Name:
Anonymous2009-05-23 18:23
>>6
This is the true power of currying and composition.
>>9 Expert BBCode
Copyright (C) 1999 Anonymous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>;.
Name:
Anonymous2009-05-24 14:26
>>11Copyright 1999 Anonymous. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must
display the following acknowledgement:
For God so loved the world, that he gave his only begotten Son, that
whosoever believeth in him should not perish, but have everlasting life.
(John 3:16, King James Bible)
4. Neither the name "Expert BBCode" nor the names of its developers may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.