Search found 192 matches

by trubblegum
Mon Apr 23, 2012 7:07 am
Forum: Support and Development
Topic: Not equals to (number to number)
Replies: 7
Views: 3333

Re: Not equals to (number to number)

Actually, what OP specified was not inrange(x, 16, 20) - between(x, 16, 20) implies exclusion of the range limits, 16 and 20.
So :

Code: Select all

function inrange(x, lower, upper)
  return x >= lower and x <= upper
end

if not inrange(x, 16, 20) then end
You were closer the first time ;)
by trubblegum
Sat Apr 21, 2012 10:02 am
Forum: Support and Development
Topic: Regular Expressions
Replies: 13
Views: 2420

Re: Regular Expressions

The problem is altering a game of hangman, so that it uses pattern matching as its primary method of evaluation, instead of iterating over a table of characters. I suppose what I meant was ".. the problem of a game of hangman ..". This : guess:iAmPartOfTheSolution(iAmAnotherPartOfTheSolution) Not th...
by trubblegum
Sat Apr 21, 2012 7:43 am
Forum: Support and Development
Topic: Main function (tables) of a Hangman-clone
Replies: 11
Views: 1771

Re: Main function (tables) of a Hangman-clone

Sorry .. failed to reply on this one : Also, why "love.draw = function()" instead of "function love.draw()"? Basically, because I can, and I hate magic syntax where there's no call for it. The function is a member of the love table, so it's a more accurate representation of what's going on (declarin...
by trubblegum
Fri Apr 20, 2012 7:13 pm
Forum: Support and Development
Topic: Main function (tables) of a Hangman-clone
Replies: 11
Views: 1771

Re: Main function (tables) of a Hangman-clone

Yeah .. thanks, Roland, but where's your homework? :P
by trubblegum
Fri Apr 20, 2012 12:20 pm
Forum: Support and Development
Topic: Regular Expressions
Replies: 13
Views: 2420

Re: Regular Expressions

Can't give account for that, as it's not my code.
by trubblegum
Fri Apr 20, 2012 11:53 am
Forum: Support and Development
Topic: Regular Expressions
Replies: 13
Views: 2420

Re: Regular Expressions

Not what I was looking for. What I want is a solution to the problem of the game of hangman, which eliminates the word and guess tables altogether, and uses pattern matching to operate directly on strings. You should be able to do it by replacing the elseif with a single line (not counting the reset...
by trubblegum
Thu Apr 19, 2012 9:08 pm
Forum: Support and Development
Topic: invalid parameter expected userdata(for the nth time)
Replies: 4
Views: 751

Re: invalid parameter expected userdata(for the nth time)

Don't know what's happening in char.lua, so can't comment.
by trubblegum
Thu Apr 19, 2012 8:22 pm
Forum: Support and Development
Topic: Regular Expressions
Replies: 13
Views: 2420

Re: Regular Expressions

Fortunately most modern languages have native support or standard library support for regex (or in Lua's case, an ultra-minimal variant). This appears to be true. PS : Hey, I found you one. Rewrite this to use pattern matching instead of its current table-based approach : https://love2d.org/forums/...
by trubblegum
Thu Apr 19, 2012 7:54 pm
Forum: Support and Development
Topic: Main function (tables) of a Hangman-clone
Replies: 11
Views: 1771

Re: Main function (tables) of a Hangman-clone

explode = function(str) local t = {} for i = 1, str:len() do t[i] = str:sub(i, i) end return t end implode = function(t) local str = '' for i, v in ipairs(t) do str = str .. v end return str end newword = function() local word = explode(words[math.ceil(math.random() * #words)]) local guess = {} for...