I gotta have my orange juice.

Jesu, Juva

Archive for November 2004

Comfort and Joy

leave a comment »

Discussion questions on chapters 7-8 of Christ Our Mediator, by C. J. Mahaney.

Summary

Chapter 7, What God Understands. Because of Jesus’s suffering, there is comfort to be found at the cross for the suffering Christian. The cross puts the degree of our suffering in perspective; our suffering, though very real, is light and momentary by comparison, for Jesus has suffered God’s full wrath for our sin. And as a result of His own suffering, Jesus understands our suffering intimately. But more than that, because He suffered for our sake, He brings real comfort to us in our own suffering: He intercedes for us before the Father, and He gives us the Holy Spirit.

Chapter 8, Assurance and Joy. Because of what Jesus has accomplished for us, there is joy to be found at the cross in the midst of our suffering as Christians. He suffered God’s wrath for our sake, to rescue us from that wrath and bring us mercy. All of our suffering is eclipsed by the staggering greatness of this gift, even moreso because we are entirely undeserving of God’s kindness. The cross assures us of God’s unfailing and personal love for us. The cross should be for us an unending source of “joy inexpressible and full of glory”.

Questions

  1. CJ quoted Spurgeon as writing that “we little know what we owe to our Savior’s prayers,” that not until heaven will we see the the full and amazing extent of Jesus’s intercession for us before the Father. Yet looking back even now, can you identify some specific ways in which it is clear that God has shown mercy and compassion to you in the midst of suffering? The goal here is both to build faith and also encourage thankfulness and praise.
  2. CJ describes a doctor dying of AIDS and writes that “Jesus was with [him and his wife]. That was all either of them needed to know. Because that is always enough. . . . He is always present. . . and that is sufficient.” What does it mean to say that Jesus is sufficient? ”We do not need anything other than Him, and we do not need anything more than Him.” How have you found this to be true in your life? How is Jesus present and sufficient for you here and now?
  3. Often we allow ourselves to be ruled by subjective feelings and appearances; we might feel that God has abandoned us, that He does not care or understand, or that a situation is insurmountable. When we are overwhelmed by feelings or appearances, the only counsel that the world has to offer is to convince ourselves we’re okay on the one hand, or on the other to grimly bear pain in our own strength. But for the Christian there are objective realities that bring genuine comfort and even joy in the midst of suffering. When we are tempted by subjective appearances to despair, what objective truths must we flee to as our anchor and hope? The gospel, the cross, the amazing and undeserved mercy God has shown us in our sin, God’s declaration of His eternal love, God’s faithfulness. . . When we are captivated by subjective appearances, why is it not only good, but right, to flee to the cross? By giving ourselves to subjectivity we are not merely misguided or short-sighted, but are living in unbelief.
  4. Read Habakkuk 3:17-19. In the midst of his trials, where was Habakkuk’s focus? In the God of his salvation. Why was this the right attitude for Habakkuk — and us — to have? God has proven His love (we can see this even more clearly than Habakkuk, since we look back on the cross); God’s kindness and salvation far outweigh our suffering; and we do not know better than God in His sovereignty, wisdom, and love. Does this attitude come naturally for Habakkuk, or us? Habakkuk struggled for three chapters, complaining to God, and only in the end came to realize what was most important. Likewise, in our suffering, we must exercise faith to have this outlook.
  5. CJ quotes Thomas Watson as writing that “your sufferings are not so great as your sins: put these two in the balance, and see which weighs heaviest.” When we consider the full weight of our sin, how does that put our suffering in perspective? First, we deserve far worse suffering. Second, God has been amazingly merciful to us. How should this provoke us to respond to suffering? With humility, gratefulness for mercy, joy.
  6. Read Galatians 2:20. CJ counsels us to flee to the cross as our only hope and the source of true joy. What encouragement can we draw from this verse in particular? Jesus is the source of our life; Jesus loves us personally; Jesus gave Himself for us personally. Why is Jesus’ personal love and sacrifice for us so amazing? First, God’s particular and personal love gives us great comfort and assurance: we haven’t stumbled upon His grace accidentally, but rather He set His love on us, individually. Second, the fact that He loved us beforehand, even knowing our sins, is humbling and amazing.
  7. God actually commands us to serve Him with joy (Ps. 100:2; Deut. 28:47-48). Obviously joy is not the fruit of a wooden obedience; CJ reminds us that our joy is found by seeing our savior and the cross with eyes of faith, exhorting us to “let the cross always be the treasure of your heart, your best and highest thought. . . and your passionate preoccupation.” What are some practical ways you have found helpful to keep the cross your “passionate preoccupation”? Study the gospels and epistles; study books on the cross; make the cross a regular subject of meditation, prayer, and song; . . .
  8. What are some of the many ways that considering the cross produces real joy? Name some specific ways the cross has brought comfort and joy to you in the past, or how it can bring comfort and joy to a present situation you are experiencing. This would be a good bridge to a time of spontaneous thanksgiving and praise in closing.
  9. Possible ways to close the meeting:
    • End with a time of prayer or praise to allow for spontaneous expressions of gratitude and joy in the cross.
    • Pray for those who are experiencing suffering, hardship, or trials.
    • Pray for those who desire greater assurance. While a lack of assurance is usually a sign of looking for it in the wrong place (emotions or self-righteousness rather than Christ), God does give us assurance in His word and by His Holy Spirit.

Written by Scott Moonen

November 24, 2004 at 11:11 am

Python odd word problem

leave a comment »

I crafted this compact solution to Dijkstra’s OddWordProblem:

from sys import stdin, stdout
def even(char) : stdout.write(char); return select(even, 0, "");
def odd(char)  : q = select(odd, 0, ""); stdout.write(char); return q
def select(fn, skipspace, prefix) :
  char = stdin.read(1)
  if char.isspace() and skipspace : return select(fn, 1, prefix)
  elif char.isspace()             : return 0
  elif char.isalpha()             : stdout.write(prefix); return fn(char)
  elif char == "."                : return 1
  else                            : raise "Invalid input"

if not select(even, 1, "") :
while not select(odd, 1, " ") and not select(even, 1, " ") : pass
stdout.write(".")

Written by Scott Moonen

November 10, 2004 at 5:36 am

Posted in Python

Tagged with ,

Python list partition

leave a comment »

I came up with these simple solutions to RonJeffriesCodingProblem. The first uses Python 2.2’s generators, the second uses the functional idiom, and the third uses list comprehensions. The third is my favorite:

def split1(list, num) :
  for index in range(num) :
    yield list[index * len(list) / num:(index + 1) * len(list) / num]

def split2(list, num) :
  return map(lambda x: list[x * len(list) / num:(x+1) * len(list) / num], range(num))

def split3(list, num) :
  return [list[x*len(list)/num : (x+1)*len(list)/num] for x in range(num)]

Written by Scott Moonen

November 9, 2004 at 2:10 pm

Posted in Python

Tagged with ,

Python Timestamp Increment

leave a comment »

I composed this concise solution to ncm‘s “coding challenge” in November 2004. I’m not entirely satisfied with its elegance, but I’m pleased with its brevity.

def dateinc(s) :
  def carry(list, modulus) :
    if len(list) == 1 : return [list[0] // modulus[0], list[0] % modulus[0]]
    else              : q = carry(list[1:], modulus[1:]); return [(list[0] + q[0]) // modulus[0], (list[0] + q[0]) % modulus[0]] + q[1:]
  s = reduce(lambda x,y:x+y, map(lambda x : (x >= '0' and x <= '9') * x, s))
  result = map(lambda x,y:x+y, map(int,(s[0:4],s[4:6],s[6:8],s[8:10],s[10:12],s[12:14])),(0,-1,-1,0,0,1))
  modulus = [10000,12,[31,28,31,30,31,30,31,31,30,31,30,31][result[1]],24,60,60]
  if result[0] % 4 == 0 and (result[0] % 100 != 0 or result[0] % 400 == 0) :
    modulus[2] += 1                               # Account for leap day.
  result = carry(result, modulus)[1:]             # Carry the extra second.
  result[1:3] = map(lambda x:x+1, result[1:3])    # Readjust to 1-base.
  return reduce(lambda x,y:x+y, map(lambda x : (x < 10) * '0' + str(x), result))

I further reduced this as follows, turning the carry function into a one-liner that computes the carry in-place (and also using builtins wherever possible). I’m much more satisfied with this solution.

def dateinc(s) :
  s = reduce(lambda x,y:x.isdigit()*x+y.isdigit()*y, s)
  ans = map(int.__add__, map(int,(s[0:4],s[4:6],s[6:8],s[8:10],s[10:12],s[12:14])),(0,-1,-1,0,0,1))
  mod = [10000,12,[31,28,31,30,31,30,31,31,30,31,30,31][ans[1]],24,60,60]
  if ans[0] % 4 == 0 and (ans[0] % 100 != 0 or ans[0] % 400 == 0) : mod[2] += 1
  ans = map(lambda x:(ans[x] + reduce(int.__mul__, map(lambda y:ans[y]>=mod[y]-1,range(x+1,len(ans))),x!=len(ans)-1)) % mod[x], range(len(ans)))
  ans[1:3] = map(int.__add__,ans[1:3],[1,1])      # Readjust to 1-base.
  return reduce(str.__add__, map(lambda x : (x < 10) * '0' + str(x), ans))

Written by Scott Moonen

November 9, 2004 at 12:52 pm

Posted in Python

Tagged with